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.

//题意:abc代表,三个颜色的岛的数量,现要建桥,要求同色岛间距离至少为3,求有多少种方式建桥

//发现a、b和a、c以及b、c的关系是独立的,可以先只考虑a和b之间连边的方案数:假设a≤b则方案数为Pab=∑ai=0 Cia×Aib,所以答案为PabPbcPac

 #include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LL long long
#define MX 5005 int a, b, c; LL Ast[MX]; LL inv(LL x)
{
LL ret = , n = MOD-;
while (n)
{
if (n%) ret = ret*x%MOD;
x=x*x%MOD;
n/=;
}
return ret;
} LL A(int x,int y)
{
return Ast[x] * inv(Ast[x-y])%MOD;
} LL C(int x,int y)
{
return A(x,y) * inv(Ast[y])%MOD;
} int main()
{
Ast[]=;
for (int i=;i<=;i++)
Ast[i] = Ast[i-]*i%MOD; while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
LL ans = , temp = ;
for (int i=;i<=min(a,b);i++)
temp=(temp+C(a,i)*A(b,i)%MOD)%MOD;
ans=ans*temp%MOD; temp = ;
for (int i=;i<=min(b,c);i++)
temp=(temp+C(b,i)*A(c,i))%MOD;
ans=ans*temp%MOD; temp=;
for (int i=;i<=min(a,c);i++)
temp=(temp+C(a,i)*A(c,i))%MOD;
ans=ans*temp%MOD;
printf("%I64d\n",ans);
}
return ;
}

The Intriguing Obsession的更多相关文章

  1. code forces 439 C. The Intriguing Obsession

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

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

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

  3. Codeforces Round #439 (Div. 2) C. The Intriguing Obsession

    C. The Intriguing Obsession 题目链接http://codeforces.com/contest/869/problem/C 解题心得:     1.由于题目中限制了两个相同 ...

  4. Codeforces 869C The Intriguing Obsession

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

  5. Codeforces Round #439 C. The Intriguing Obsession

    题意:给你三种不同颜色的点,每种若干(小于5000),在这些点中连线,要求同色的点的最短路大于等于3或者不连通,求有多少种连法. Examples Input 1 1 1 Output 8 Input ...

  6. CF869C The Intriguing Obsession(组合数学瞎搞,O(n)莫名过)

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

  7. 「日常训练」The Intriguing Obsession(CodeForces Round #439 Div.2 C)

    2018年11月30日更新,补充了一些思考. 题意(CodeForces 869C) 三堆点,每堆一种颜色:连接的要求是同色不能相邻或距离必须至少3.问对整个图有几种连接方法,对一个数取模. 解析 要 ...

  8. Codeforces 869C The Intriguing Obsession:组合数 or dp

    题目链接:http://codeforces.com/problemset/problem/869/C 题意: 红色.蓝色.紫色的小岛分别有a,b,c个. 你可以在两个不同的岛之间架桥,桥的长度为1. ...

  9. 【CF Round 439 C. The Intriguing Obsession】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

随机推荐

  1. 微信团队分享:iOS版微信的高性能通用key-value组件技术实践

    本文来自微信开发团队guoling的技术分享. 1.前言 本文要分享的是iOS版微信内部正在推广和使用的一个高性能通用key-value 组件的技术实践过程,该组件在微信内部被命名为MMKV(以下简称 ...

  2. android开发全然退出activity

    我们退出Activity能够调用:finish(),system(0),可是这些都仅仅是单单退出单个Activity 也有人会说,直接把进程杀死,这些做法都不是非常可取.事实上我们翻看api能够发现. ...

  3. linux后台运行命令

    Ctrl+z/bg/nohup/setsid/& screen 区别待续

  4. 字符串算法之 AC自己主动机

    近期一直在学习字符串之类的算法,感觉BF算法,尽管非常easy理解,可是easy超时,全部就想学习其它的一些字符串算法来提高一下,近期学习了一下AC自己主动机.尽管感觉有所收获,可是还是有些朦胧的感觉 ...

  5. 几个div并列显示效果消除之间的间隔

    今天在做一个静态页面时,头部的广告条是很大一张图片,考虑到网页访问时的加载速度,因此需要把一幅图拆成几个尺寸较小的图片来作为背景图,但是采用div来布局时,出现了div不能显示在一行的情况,所以开始想 ...

  6. linux学习之缓存机制

    linux中的缓存机制 在Linux系统中,为了提高文件系统性能,内核利用一部分物理内存分配出缓冲区,用于缓存系统操作和数据文件,当内核收到读写的请求时,内核先去缓存区找是否有请求的数据,有就直接返回 ...

  7. layui实现table表格的“关键字搜索”功能

    $('#searchBtn').on('click',function(){ var type = $(this).data('type'); active[type] ? active[type]. ...

  8. iOS视频压缩存储至本地并上传至服务器

    最近做了一个项目,我把其中的核心功能拿出来和大家分享一下,重点还是自己梳理一下. 这里关于视频转码存储我整理了两个方法,这两个方法都是针对相册内视频进行处理的. 1.该方法没有对视频进行压缩,只是将视 ...

  9. 如何解决局域网中Windows防火墙不能访问Oracle问题!

    在防火墙例外中,添加端口1521端口就样局域网内的其他机器就可以访问你的ORACLE了. 在防火墙的入站规则中,新建端口规则.过程如下例图片所示:

  10. linux fedora 14(内核2.6.35.6) PF_RING+libpcap 极速捕获千兆网数据包,不丢包

    前面讲到了libpcap 捕获数据包,尤其在千兆网的条件下,大量的丢包,网上搜索好久,大概都是PF_PACKET +MMAP,NAPI,PF_RING之类的方法,我对PF_RING+libpcap进行 ...