C. The Intriguing Obsession
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

— This is not playing but duty as allies of justice, Nii-chan!

— Not allies but justice itself, Onii-chan!

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 ab 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 ab 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 998 244 353.

Examples
input
1 1 1

output
8

input
1 2 2

output
63

input
1 3 5

output
3264

input
6 2 9

output
813023575

Note

In the first example, there are 3 bridges that can possibly be built, and no setup of bridges violates the restrictions. Thus the answer is23 = 8.

In the second example, the upper two structures in the figure below are instances of valid ones, while the lower two are invalid due to the blue and purple clusters, respectively.

题意:有三堆群岛,分别用不同颜色标记,现在在岛间建桥连边,长度统一为1,在限制条件同一种颜色的桥距离最小为三的情况下,有多少种方法建桥(结果模998244353)。

思路:先把三种岛的集合根据岛的数量排序,按照要求一种群岛可以选择其中几个岛向其他群岛中的岛一对一连边,而不能一对多或者多对一,否则则会违反距离最小为3的限制。所以分别讨论两个集合中连边的情况最后在把他们相乘即可。

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
#define maxn  5005
__int64 C[maxn][maxn];
const int MOD=998244353;
void get_C(__int64 x)     //组合数初始化
{C[0][0] = 1;for(int i=1;i<=x;i++){C[i][0] = 1;for(int j=1;j<=i;j++)C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD;}
}
__int64 jiecheng(int x)     //阶乘
{__int64 ans=1;for(int i=1;i<=x;i++){ans*=i;ans%=MOD;}return ans;
}
int main()
{get_C(5000);int a,b,c;while(~scanf("%d%d%d",&a,&b,&c)){if(a<b)swap(a,b);if(a<c)swap(a,c);if(b<c)swap(b,c);__int64 ans=1;__int64 temp=0;for(int i=0;i<=c;i++)     //a、c连边 {temp+=((C[a][i]*C[c][i]%MOD)*jiecheng(i)%MOD);temp%=MOD;}ans*=temp;ans%=MOD;temp=0;for(int i=0;i<=c;i++)     //b、c连边 {temp+=((C[b][i]*C[c][i]%MOD)*jiecheng(i)%MOD);temp%=MOD;}ans*=temp;ans%=MOD;temp=0;for(int i=0;i<=b;i++)          //a、b连边 {temp+=((C[a][i]*C[b][i]%MOD)*jiecheng(i)%MOD);temp%=MOD;}ans*=temp;ans%=MOD;printf("%I64d\n",ans);}
}

codeforces 869c(组合数)相关推荐

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

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

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

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

  3. Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学

    - This is not playing but duty as allies of justice, Nii-chan! - Not allies but justice itself, Onii ...

  4. Codeforces1600数学[CodeForces - 958E1[平面几何+暴力]CodeForces - 888D [组合数+错排问题]]

    A - Guard Duty (easy) CodeForces - 958E1 题目大意:给你n个基地和m个飞船,每个基地都要分配一共飞船,每个飞船都要在一共基地,任意两台飞船到基地得直线路径上不能 ...

  5. Codeforces 869C The Intriguing Obsession

    题意:有三种颜色的岛屿各a,b,c座,你可以在上面建桥.联通的点必须满足以下条件:1.颜色不同.2.颜色相同且联通的两个点之间的最短路径为3 其实之用考虑两种颜色的即可,状态转移方程也不难推出:F[i ...

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

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

  7. 一句话题解(20170801~20170125)

    8.1 bzoj 4720 noip2016 换教室 floyd预处理+期望(薛定谔的猫) bzoj 4318 OSU! 三次函数期望值 从一次.二次推得 8.2 bzoj 1076 状压+期望DP ...

  8. 【dp专题】在经历了时空扭曲后的总结

    在很久很久很久以后,我终于又回到了coder的舞台. 那么我们来水一发dp吧! 好懒啊不想动 字符染色 [原题]BZOJ 2958 题目描述 给出一个长度为N由B.W.X三种字符组成的字符串S,你需要 ...

  9. Codeforces 785 D.Anton and School - 2(组合数处理)

    Codeforces 785 D.Anton and School - 2 题目大意:从一串由"(",")"组成的字符串中,找出有多少个子序列满足:序列长度为偶 ...

最新文章

  1. 在Ubuntu下怎么截图
  2. linux下安装mysql初始化报错:bin/mysqld: error while loading shared libraries: libnuma.so.1
  3. 中序遍历的非递归算法
  4. 程序员们,您还想熬夜吗?
  5. 探秘Tomcat(一)——Myeclipse中导入Tomcat源码
  6. 《看聊天记录都学不会C语言?太菜了吧》(12)循环有多容易?你看一眼就怀...
  7. 【渝粤题库】国家开放大学2021春2047商业银行经营管理题目
  8. hook 输入法 android,安卓输入法输入性能评测流程
  9. 你了解node多进程吗
  10. Vue学习笔记之01-Vue的特点
  11. java分页查询代码实现
  12. 目标追踪笔记---帧差法
  13. ERP业务流程优化设计之思想和原则
  14. 高项_第九章人力资源管理
  15. 多传感器信息融合,介绍中图片为INS+ DVL组合程序
  16. 云服务器与物理服务器有什么区别?
  17. 霍元甲被日本人用烂肺药毒死(图)
  18. Python 北京二手房成交数据分析过程
  19. 使用 Bumblebee 控制 NVIDIA 双显卡(ubuntu13.04-X64)
  20. 视频清晰度与数据密度

热门文章

  1. Linux之LVM篇
  2. 港科夜闻|香港科技大学与英国思克莱德大学深化研究合作
  3. FlowNet:使用卷积网络学习光流
  4. 入网许可证_入网许可证查询
  5. 微信扫码登录只能填一个授权回调域问题
  6. java 红外光谱数据库_【分享】免费的20个谱图数据库 - 晶体 - 小木虫 - 学术 科研 互动社区...
  7. win10 卸载cuda
  8. stm32L1151用cube配置ADC
  9. java xml中的冒号_带冒号的xml元素名称
  10. 查看MySQL的版本号