【Codeforces 869 C The Intriguing Obsession】& 组合数学 & 思维
来源:互联网 发布:卡通农场有mac版吗 编辑:程序博客网 时间:2024/06/10 22:14
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】& 组合数学 & 思维
- codeforces 869C The Intriguing Obsession 组合数学,逆元
- Codeforces 869 C. The Intriguing Obsession (组合数学)
- codeforces 869C. The Intriguing Obsession(组合数学)
- codeforces 869C The Intriguing Obsession 组合数学
- Codeforces Round #439 C.The Intriguing Obsession(组合数学)
- Codeforces 869C ( Codeforces Round #439 (Div. 2) ) The Intriguing Obsession 组合数学
- Codeforces Round #439 (Div. 2) C 869C The Intriguing Obsession(思维+简单组合)
- Codeforces 869C The Intriguing Obsession【组合数】
- Codeforces-869C The Intriguing Obsession(DP/组合数)
- CodeForces 869C The Intriguing Obsession【排列组合】
- Codeforces Round #439 (Div. 2) C The Intriguing Obsession (组合数学)
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 组合数学
- #439 Div.2 C. The Intriguing Obsession 组合数学
- Codeforces Round #439 C.The Intriguing Obsession(DP + 思维)
- Codeforces Round #439 C. The Intriguing Obsession (组合数)
- Codeforces Round #439C 组合数-The Intriguing Obsession
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 数学
- 显示时间与输出管理
- POJ
- [ReactNative]Unable to load script form assets
- #Java 核心技术卷一阅读笔记# 第十一章 事件处理
- swiper实现今日头条导航效果,在官方demo实现全部代码
- 【Codeforces 869 C The Intriguing Obsession】& 组合数学 & 思维
- centos自启动脚本
- mysql 内置函数大全
- selenium接口测试
- 跨域问题
- MySQL触发器
- Idea 2017配置struts2--超坑爹问题解决
- leetcode解题方案--005--Longest Palindromic Substring
- python处理JSON格式数据并利用pygal绘制世界地图