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. Windows正在使用无法停止通用卷怎么办

    最后解决方案1: 1.双击任务栏上的安全删除硬件图标 2.按下Ctrl + Alt + Del 组合键调出"任务管理器": 3.结束其中的explorer.exe进程,此时桌面上的 ...

  2. vue-cli webpack 中全局引入 jquery

    1.安装 jquery npm install jquery --save-dev 2.修改 webpack.base.conf.js 方法一 首先加入: const webpack = requir ...

  3. 一种大气简单的Web管理(陈列)版面设计

    在页面的设计中,多版面是一种常见的设计样式.本文命名一种 这种样式.能够简单描写叙述为一行top,一列左文件夹,剩余的右下的空间为内容展示区.这种样式,便于高速定位到某项内容或功能. 在主要的HTML ...

  4. Ant 风格路径表达式(转)

    ANT通配符有三种: 通配符 说明 ? 匹配任何单字符 * 匹配0或者任意数量的字符 ** 匹配0或者更多的目录 例子: URL路径 说明 /app/*.x 匹配(Matches)所有在app路径下的 ...

  5. 使用CXF实现基于Soap协议的WebService

    本文介绍使用CXF实现基于Soap协议的WebService(CXF的版本是3.0.0) 一. 前言 Java有三种WebService规范:Jax-WS,Jax-RS,Jaxm 1. Jax-WS( ...

  6. 剑指Offer-正则表达式匹配(Python)

    1 题干内容 请实现一个函数用来匹配包括.和*的正则表达式.模式中的字符.表示任意一个字符,而*表示它前面的字符可以出现任意次(包含0次). 在本题中,匹配是指字符串的所有字符匹配整个模式. 例如,字 ...

  7. hdu5305Friends dfs

    //给一个无向图 , 每条边能够是online边也能够是offline边,问 //有多少种方法使得每一个节点的online边和offline边一样多 #include<cstdio> #i ...

  8. Atitit.upnp SSDP 查找nas的原理与实现java php c#.net c++

    Atitit.upnp SSDP 查找nas的原理与实现java php c#.net c++ 1. 查找nas的原理1 2. 与dlna的关系1 3. 与ssdp的关系1 4. Cling - Ja ...

  9. Xilinx_7_Series_GTX简介

    Xilinx_7_Series_GTX简介 https://wenku.baidu.com/view/4639cde7bb68a98270fefab6.html

  10. sql语句单据编号生成防并发

    有用户反馈说发现重复单据号,检查发现以下单据号被分配给了不同的两个职工 系统中使用语句exec GetNewOrderNumber 'pwgnumber','PWG',1, @pwg_number o ...