— 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 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个群岛,每个群岛中有一些互不相同的岛屿,现在建一些桥,使得同一群岛内的两个岛屿要么不连通要么最短路至少经过3条桥。给定三个群岛包含的岛数,求合法的建桥的方案数。

  显然有某个群岛中的某个岛只能连接其他群岛中的一个岛。群岛与群岛之间的建桥互相独立,所以考虑分开计算。

  考虑两个群岛之间建立k座桥,那么方案数就是

  所以对于两个群岛之间的建桥方案数for一遍就求完了,最后把答案乘起来就行了。

Code

 1 /**
 2  * Codeforces
 3  * Problem#869C
 4  * Accepted
 5  * Time: 30ms
 6  * Memory: 0k
 7  */
 8 #include <bits/stdc++.h>
 9 #ifndef WIN32
10 #define Auto "%lld"
11 #else
12 #define Auto "%I64d"
13 #endif
14 using namespace std;
15
16 #define ll long long
17
18 void exgcd(ll a, ll b, ll& d, ll &x, ll &y) {
19     if(!b)    {
20         d = a, x = 1, y = 0;
21     } else {
22         exgcd(b, a % b, d, y, x);
23         y -= (a / b) * x;
24     }
25 }
26
27 ll inv(ll a, ll n) {
28     ll d, x, y;
29     exgcd(a, n, d, x, y);
30     return (x < 0) ? (x + n) : (x);
31 }
32
33 const int moder = 998244353;
34 int a, b, c;
35
36 inline void init() {
37     scanf("%d%d%d", &a, &b, &c);
38 }
39
40 long long calc(int x, int y) {
41     long long rt = 1;
42     long long Px = 1, Py = 1;
43     for(int i = 1; i <= x && i <= y; i++) {
44         Px = (Px * (x - i + 1) % moder) * inv(i, moder) % moder;
45         Py = (Py * (y - i + 1)) % moder;
46         rt = (rt + (Px * Py % moder)) % moder;
47     }
48     return rt;
49 }
50
51 inline void solve() {
52     long long ra = calc(a, b);
53     long long rb = calc(b, c);
54     long long rc = calc(c, a);
55     long long res = ((ra * rb) % moder) * rc % moder;
56     printf(Auto, res);
57 }
58
59 int main() {
60     init();
61     solve();
62     return 0;
63 }

转载于:https://www.cnblogs.com/yyf0309/p/7635476.html

Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学相关推荐

  1. Codeforces Round #732 (Div. 2) D. AquaMoon and Chess 组合数学 + 找规律

    传送门 文章目录 题意: 思路: 题意: 给你一个010101串,当且仅当某个111的某一边i+1,i−1i+1,i-1i+1,i−1有111,这个111可以跟i+2,i−2i+2,i-2i+2,i− ...

  2. Codeforces Round #724 (Div. 2) F. Omkar and Akmar 组合数学 + 博弈

    传送门 文章目录 题意: 思路: 题意: 思路: 首先我们先来研究一下这个游戏,手画几个会惊奇的发现,后手这个b怎么怎么画都赢啊???对,没错,就是怎么画都赢,下面我们来证明一下为什么后手怎么画都赢. ...

  3. Codeforces Round #770 (Div. 2) Problem B.Fortune Telling

    题意: 给定两个数,Alice的数x, Bob的数 x + 3,和一个长度为n的数组a,x和x + 3都要和a的每一个数执行 "加法" 或 "异或" 两个操作的 ...

  4. Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读

    http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...

  5. Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维线段树||二维树状数组

    http://codeforces.com/contest/869/problem/E 题意:n*m的矩阵,q次操作,三种类型 类型1:给指定矩阵加上围栏 类型2:给指定矩阵去掉围栏 类型3:查询两点 ...

  6. Codeforces Round #439 (Div. 2) E. The Untended Antiquity

    E. The Untended Antiquity Problem Statement Adieu l'ami.     Koyomi is helping Oshino, an acquaintan ...

  7. Codeforces Round #439 (Div. 2) A. The Artful Expedient

    A. The Artful Expedient Problem Statement Rock- Paper!     After Karen have found the deterministic ...

  8. Codeforces Round #372 (Div. 2), problem: (B) Complete the Word

    水题,每次截取长度为26的字符串,然后直接进行修改就可以 然而本弱渣昨天wa看很久 include<bits/stdc++.h> using namespace std; int n,c; ...

  9. Codeforces Round #368 (Div. 2) problem: (C) Pythagorean Triples

    本题就一个公式 n^2+((n^2-1)/2)^2=((n^2+1)/2)^2 0.当n==1或n==2时,不存在结果. 1.当n为奇数时此公式求得的数还是整数,成立 2.当n为偶数时分两种情况: ( ...

最新文章

  1. php 支付宝支付 简书,支付宝支付接口
  2. Sitecore 8.2 页面架构设计:模板与组件
  3. HBase-存储-HFile格式
  4. 软件设计原则(二) 接口隔离原则
  5. 小程序毕设作品之微信小程序点餐系统毕业设计(4)开题报告
  6. PLSQL使用常用技巧
  7. 如何在谷歌地图自定义范围_如何在Google地图中创建自定义地图
  8. BIOS的设置.注册表的修改与电脑故障的排除
  9. 问题解决:“nginx: [emerg] unknown directive “ “ in /etc/nginx/conf.d/XXX.conf:122”
  10. 指向指针的指针!!(能让初学者绕晕的东西)
  11. 昆山市地方税务局异地复制及备份系统询价采购招标公告
  12. 我所理解的技术领导力
  13. 翼机通,别让垄断的剑刺向自己
  14. VHDL设计——电梯控制器模块
  15. 字符串ASCLL排序 Java
  16. classtwo_单表查询
  17. ps学习资料,很有用的!
  18. Date、Calendar类
  19. Fastjson反序列化
  20. 深度学习(PyTorch)——卷积神经网络(CNN)基础篇

热门文章

  1. ES6——class类的继承与静态方法
  2. 简单易懂的宏任务和微任务执行顺序
  3. LINUX NGINX 环境禁止访问指定后缀文件
  4. 关键词排名提升(提升关键词排名的方法)
  5. UBuntu18.04 Qt之双HDMI接2个4K屏并分别设置分辨率、主屏、副屏
  6. 我了解到的新知识之----遇到路由器DNS被篡改我该怎么办?
  7. 家里的老电脑,是升级硬件好,还是重新买一个好?
  8. MSVC X64 函数中的 RSP, RBP 和 Calling Convention
  9. 知物由学 | Android应用破解与防护,阻断猖獗的应用乱象
  10. PDF如何删除数字签名