— 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 1
output
  1. 8
input
  1. 1 2 2
output
  1. 63
input
  1. 1 3 5
output
  1. 3264
input
  1. 6 2 9
output
  1. 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 = , y = ;
  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 < ) ? (x + n) : (x);
  31. }
  32.  
  33. const int moder = ;
  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 = ;
  42. long long Px = , Py = ;
  43. for(int i = ; i <= x && i <= y; i++) {
  44. Px = (Px * (x - i + ) % moder) * inv(i, moder) % moder;
  45. Py = (Py * (y - i + )) % 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 ;
  63. }

Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学的更多相关文章

  1. Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分

    Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...

  2. Codeforces Round #439 (Div. 2) Problem B (Codeforces 869B)

    Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense ...

  3. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力

    Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...

  4. Codeforces Round #439 (Div. 2)【A、B、C、E】

    Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...

  5. Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维

    & -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...

  6. Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation

    还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门  Problem - D - Codeforces 题意 n个数字,n ...

  7. Codeforces Round #771 (Div. 2), problem: (B) Odd Swap Sort

    Problem - B - Codeforces 就是给你个序列, 给他整成升序的, 每次操作可以使相邻两个数交换位置, 交换条件是二数之和为奇数 结果只需输出是否可以整成升序的 思路: 需要奇数偶数 ...

  8. Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】

    题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...

  9. Codeforces Round #754 (Div. 2), problem: (A) A.M. Deviation泪目 万万没想到狂wa是因为这

    Problem - A - Codeforces 题目 题意很简单每次操作可以使得a1 a2  a3任意两个数分别+1  -1 求最后使得a+c-2b绝对值的最小值 BUG就是最后忽略了-2和2这一点 ...

随机推荐

  1. 关于如何利用计算属性进行button的控制

    element分页没用它的 (这个只要上一页下一页),比如共2页的时候,你在第一页,你肯定可以点击下一页,当你进入到第二页的时候这个button肯定就不能点击了啊,它的属性diaabled=true让 ...

  2. 17.在自适应屏幕里通过JQ来获取宽高并赋给需要的

    在自适应屏幕里通过JQ来获取宽高并赋给需要的div. var height = document.documentElement.clientHeight; $(window).height();(同 ...

  3. MongoDB 在 windows 下的安装与服务配置

    本文转载地址: https://blog.csdn.net/Dorma_Bin/article/details/80851230 本地安装及网页测试 在官网下载最新的安装文件 下载地址 : https ...

  4. Nodejs【单机】多进程模式集群

    Nodejs[单机]多进程模式集群实例: 1.安装:npm install -s cluster 2.服务代码: var debug = require('debug'); var express = ...

  5. SQL中的关联更新和关联删除

    在SQL中,经常用到关联查询,比如select a.* from A a inner join B b on a.PId=b.FId where 条件,SQL中也支持类似的关联更新和关联删除. 关联更 ...

  6. 强化学习--Policy Gradient

    Policy Gradient综述: Policy Gradient,通过学习当前环境,直接给出要输出的动作的概率值.   Policy Gradient  不是单步更新,只能等玩完一个epoch,再 ...

  7. Yii2将查询数据变为键值对数组及查询构建器

  8. 前端 dojo

    http://dojotoolkit.org/documentation/tutorials/1.10/hello_dojo/ html在线编辑器 国内 http://runjs.cn 国外 http ...

  9. 修改 File --> New 菜单内容

    修改 File --> New 菜单内容 window --> Perspective --> Customize Perspective

  10. numpy 数据处理

    np.meshgrid() meshgrid 传入两个一维数组,返回第一个二维数组用第一个传入的一维数组为行,第二个传入的一维数组为列返回的第二个数组是以第二个传入的一维数组为行,第一个一维数组为列 ...