Description

With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere they’ve never reached — water-surrounded islands!

There are three clusters of islands, conveniently coloured red, blue and purple. The clusters consist of a, b and c distinct islands respectively.

Bridges have been built between some (possibly all or none) of the islands. A bridge bidirectionally connects two different islands and has length 1. For any two islands of the same colour, either they shouldn’t be reached from each other through bridges, or the shortest distance between them is at least 3, apparently in order to prevent oddities from spreading quickly inside a cluster.

The Fire Sisters are ready for the unknown, but they’d also like to test your courage. And you’re here to figure out the number of different ways to build all bridges under the constraints, and give the answer modulo 998 244 353. Two ways are considered different if a pair of islands exist, such that there’s a bridge between them in one of them, but not in the other.

Input

The first and only line of input contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 5 000) — the number of islands in the red, blue and purple clusters, respectively.

Output

Output one line containing an integer — the number of different ways to build bridges, modulo 998244353.

Examples input

1 1 1

Examples output

8

题意

在三种颜色的岛屿之间建立桥梁,每一种颜色的岛屿分别有 a,b,ca,b,c 个,且相同颜色的岛屿之间距离不能小于 33 ,问总共有多少种情况。

思路

显然,最终桥的排列一定类似于 abcabcabc...abcabcabc... 这样的,我们将这三种颜色点的集合抽象为空间中的一个三棱柱。

每条侧棱代表一种颜色,每个侧面上布着相邻两条侧棱之间的连线(桥),显然这样保证了相同颜色岛屿之间的距离。

我们现在只考虑一个侧面,假如相邻的两种颜色分别有 a,ba,b 个:

  • 首先,一种颜色不可以与相同的颜色相连,也就是每条侧棱中的点之间不能有连线。
  • 第二,不能有相同两个颜色的点连接到同一个点上,也就是左右两条侧棱之间点的连线无共同起点与终点,显然这样的边最多有 min(a,b)\min(a,b) 个。
  • 第三,桥的数量最少为 00 个,最多为 min(a,b)\min(a,b) 个,对于数量为 ii 的桥,我们可以从左边选取共 (ai)\binom{a}{i} 种方式,从右边选取共 (bi)\binom{b}{i} 种方式,考虑它们之间的排列共 i!i! 种,于是共有 (ai)×(bi)×i!\binom{a}{i} \times \binom{b}{i} \times i! 种组合。
  • 因此,对于每一个侧面,其贡献 f(a,b)=∑i=min(a,b)i=0(ai)(bi)i!f(a,b)=\sum_{i=0}^{i=\min(a,b)}\binom{a}{i}\binom{b}{i}i! 。

因为三个侧面之间的连线是互不干扰的,因此最终的结果为 f(a,b)×f(b,c)×f(c,a)f(a,b) \times f(b,c) \times f(c,a) 。

AC 代码

#include <bits/stdc++.h>
using namespace std;
typedef __int64 LL;
const int maxn = 5e3+10;
const int mod = 998244353;
LL mul[maxn];
LL inv[maxn];void init()
{mul[0]=1;for(int i=1; i<maxn; i++)mul[i]=(mul[i-1]*i)%mod;inv[0]=inv[1]=1;for(int i=2; i<maxn; i++)inv[i]=(LL)(mod-mod/i)*inv[mod%i]%mod;for(int i=1; i<maxn; i++)inv[i]=(inv[i-1]*inv[i])%mod;
}LL C(int n,int m)
{return mul[n]*inv[m]%mod*inv[n-m]%mod;
}LL mult(int a,int b)
{int len = min(a,b);LL ans = 0;for(int i=0; i<=len; i++)ans += C(a,i) * C(b,i) % mod * mul[i] % mod,ans %= mod;return ans;
}int32_t main()
{init();int a,b,c;cin>>a>>b>>c;LL ans = mult(a,b) * mult(b,c) %mod * mult(c,a) %mod;cout<<ans<<endl;return 0;
}

Codeforces 869 C. The Intriguing Obsession (组合数学)相关推荐

  1. 【Codeforces 869 C The Intriguing Obsession】 组合数学 思维

    C. The Intriguing Obsession time limit per test1 second memory limit per test256 megabytes inputstan ...

  2. codeforces 869C The Intriguing Obsession 组合数学,逆元

    codeforces 869C The Intriguing Obsession 题意 在三种颜色的群岛之间建造桥梁,每一种颜色分别有a,b,c 限制条件 1 相同颜色的岛之间的距离 d >= ...

  3. C. The Intriguing Obsession[组合数学]

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  4. Codeforces Round #439 C.The Intriguing Obsession(组合数学)

    C. The Intriguing Obsession time limit per test1 secondmemory limit per test256 megabytesinputstanda ...

  5. codeforces 869C The Intriguing Obsession【组合数学+dp+第二类斯特林公式】

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  6. Codeforces 869C The Intriguing Obsession 组合数取模

    Codeforces 869C The Intriguing Obsession 思考一下人生. 这是一场物语场,而且A题直接puts("Karen")能过,我对此印象非常深.我不 ...

  7. The Intriguing Obsession

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  8. C. The Intriguing Obsession

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  9. Codefrces 869C. The Intriguing Obsession

    C. The Intriguing Obsession - This is not playing but duty as allies of justice, Nii-chan! - Not all ...

最新文章

  1. 对话腾讯AI Lab:即将开源自动化模型压缩框架PocketFlow,加速效果可达50%
  2. -bash: git: command not found
  3. 多项式加法c语言数组解,急!!!!c语言:求n次多项式的加法和乘法
  4. Python Django 查询数据缓存
  5. EF Code First 学习笔记:关系(转)
  6. mysql 表数据diff,mysqldiff使用笔记
  7. 关于在vue中结合数组方法的this的指向问题
  8. java 8 lambda reduce_java8种的reduce方法和lambda表达式结合使用
  9. 为什么优秀和听话总是难两全?
  10. python将数组传入mysql_通过python将文件中的数据传输到MySQL,传到,mysql
  11. JavaScript中函数的上下文——this
  12. Tensorflow官方文档学习理解 (四)-深入MNIST
  13. vue分割开的tab组件效果
  14. 关于学习单片机keil uvision5的基本使用方法
  15. php匿名聊天室开源,[开源项目]基于WebSocket的匿名聊天室
  16. LM7805:电压调节器的工作原理
  17. 系统封装失败遇到windows 无法分析或处理
  18. 计算机中硬盘和移动硬盘的区别,笔记本硬盘和移动硬盘有什么区别
  19. 在线流程图和思维导图开发技术详解(三)
  20. MySQL数据库篇---对数据库,数据库中表,数据库中表的记录进行添修删查操作---保姆级教程

热门文章

  1. 固态硬盘比机械硬盘快的原因(科普篇)
  2. 盘点:当今十大备份应用软件
  3. 彗星mysql_为什么彗星被认为是一个“脏雪球”?
  4. win10 使用多桌面的两种方式
  5. 网桥(生成树网桥和源路由网桥)
  6. matlab如何进行批量计算,什么是matlab中逐列相关的快速计算方法
  7. 【Unity】LineRenderer画运动轨迹
  8. 1982年版《茶馆》内容简要回顾
  9. 2017北京ICPC -G - Liaoning Ship’s Voyage (HihoCoder - 1633)几何
  10. SEC S3C2410X Test B/D 驱动