C. The Intriguing Obsession
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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 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 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 is 23 = 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.

题意 : 红蓝紫 三种颜色的岛屿,同一种颜色的岛屿之间的距离 >= 3,每条边的距离为 1,最好连城的图有多少种可能

思路 : 也就是说,红色的岛屿不能同时连接两条蓝色的岛屿,只能连接一个蓝色的岛屿,也就是 a 个球放进 b 个盒子里,球不同盒子也不同,球可以不用完,每个盒子只能放一个球 sum = f(a,b) + f(b,c) + f(a,c)

某大佬的递推公式 : dp[i][j] = (dp[i-1][j-1]*j%mod + dp[i-1][j] )%mod(太强了)

AC 代码:

#include<bits/stdc++.h>
using namespace std;
const int MAX = 5e3 + 10;
const int mod = 998244353;
typedef long long LL;
LL dp[MAX][MAX],a,b,c;
LL so(LL x,LL y){if(!x || !y) return 1;else if(!dp[x][y]) dp[x][y] = (so(x - 1,y) + so(x - 1,y - 1) * y % mod) % mod;return dp[x][y];
}
int main()
{scanf("%lld %lld %lld",&a,&b,&c);LL ab = so(min(a,b),max(a,b));LL bc = so(min(b,c),max(b,c));LL ac = so(min(a,c),max(a,c));printf("%lld\n",ab * bc % mod * ac % mod);return 0;
}

【Codeforces 869 C The Intriguing Obsession】 组合数学 思维相关推荐

  1. Codeforces 869 C. The Intriguing Obsession (组合数学)

    Description With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fir ...

  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 - 1284C New Year and Permutation(组合数学+思维)

    题目链接:点击查看 题目大意:首先定义名词"排列"的意思是,一段数列中的数字升序排序后可以组成连续的一段数列,换句话说,满足一段区间内的最大值-最小值=r-l则称这个区间的数列为& ...

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

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

  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. Codeforces 869C The Intriguing Obsession 组合数取模

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

  8. The Intriguing Obsession

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

  9. C. The Intriguing Obsession

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

最新文章

  1. poj3320Jessica's Reading Problem—尺取法(java)
  2. SDUT 2133 数据结构实验之栈三:后缀式求值
  3. 习题3-11 Kickdown UVA - 1588
  4. linux怎么看是否安装kde桌面,ubuntu 7上安装kde桌面
  5. 等保2.0安全管理制度对比_一手资料!等保2.0云计算安全与风险评估
  6. 找出一棵树某一深度所有节点
  7. 95-290-380-源码-内存管理-Buffer-NetworkBufferPool简介
  8. Java工程带库编译运行
  9. 虽然今天angular5发布了,但我还是吧这篇angularjs(1)+webpack的文章发出来吧哈哈哈...
  10. 19.12添加自定义监控项目19.13/19.14 配置邮件告警19.15 测试告警19.16 不发邮件的问题处理...
  11. 动态URL、静态URl、伪静态URL
  12. 用SPSS做数据分析(1)
  13. python三菱fx3u通讯mx_[实例]三菱FX3U-485无协议通讯程序(含程序段)
  14. MIT6.828 Part B: Copy-on-Write Fork
  15. 51系列、arduino、stm32系列驱动DAC模块TLC5615输出指定电压(可修改为波形输出)
  16. 关于盗墓笔记的那些事
  17. 搭建自己的外卖红包平台,操作外卖CPS实现躺赚
  18. 华为nova10和华为nova9哪个值得买 两者配置对比
  19. PageAdmin CMS网站制作教程:如何设置会员中心权限?
  20. 微信小程序 使用 wx.downloadFile()方法

热门文章

  1. C语言:输入一个数,输出以该值为半径的圆面积,以该值为半径的球体表面积与体积,pi取值3.1415926536.
  2. 数字拼图java小程序_JS写的数字拼图小游戏代码[学习参考]
  3. C#获取文件的Content-Type(MIME Type)的三种方法
  4. 记一次笔记本连接酒店Wifi点击认证后总是报网络连接问题
  5. 游戏化是通证经济的必由之路——与游戏化专家刘沐真的对话(下)
  6. jit java同步消除_聊聊JIT是如何影响JVM性能的
  7. IPv6-GRE 隧道技术
  8. Windows留后门--教程(一)——Windows系统隐藏账户
  9. ad服务器做虚拟化,为虚拟桌面准备AD服务器
  10. IDEA全局搜索快捷键方法