C. The Intriguing Obsession

— 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 2^3 = 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种颜色每种颜色发的点数量,同种颜色不能之间相连或者连到同一个点上,问有多少中连法
思路:每个合法的点的合法连边都是独立的,所以我们可以先处理出两种颜色的合法连法在相乘即可,而两种颜色的连法就是每个点都只能最多用一次的二分图连法,可以用排列组合算出来,枚举所取点数即可

注意别爆long long

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <functional>
#include <bitset>
using namespace std;
#define LL long long
const LL mod = 998244353;
LL c[5005][5005];
LL f[5005];void init()
{f[0] = 1;for (int i = 1; i <= 5000; i++)f[i] = (f[i - 1] * i) % mod;for (int i = 0; i <= 5000; i++)c[i][0] = c[i][i]=1;for (int i = 2; i <= 5000; i++){for (int j = 1; j < i; j++)c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;}
}LL sum(int a, int b)
{int k = min(a, b);LL ans = 0;for (int i = 0; i <= k; i++){ans += ((((c[a][i] * c[b][i])%mod) * f[i])%mod);ans %= mod;}return ans;
}int main()
{int a, b, c;init();while (~scanf("%d%d%d", &a, &b, &c)){LL ans = 1;ans = (ans * sum(a, b)) % mod;ans = (ans * sum(a, c)) % mod;ans = (ans * sum(b, c)) % mod;printf("%lld\n", ans);}return 0;
}

Codefrces 869C. The Intriguing Obsession相关推荐

  1. codeforces 869C The Intriguing Obsession 组合数学,逆元

    codeforces 869C The Intriguing Obsession 题意 在三种颜色的群岛之间建造桥梁,每一种颜色分别有a,b,c 限制条件 1 相同颜色的岛之间的距离 d >= ...

  2. Codeforces 869C The Intriguing Obsession 组合数取模

    Codeforces 869C The Intriguing Obsession 思考一下人生. 这是一场物语场,而且A题直接puts("Karen")能过,我对此印象非常深.我不 ...

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

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

  4. Codeforces 869C The Intriguing Obsession

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

  5. The Intriguing Obsession

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

  6. C. The Intriguing Obsession

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

  7. C. The Intriguing Obsession[组合数学]

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

  8. Codeforces Round #439 C.The Intriguing Obsession(组合数学)

    C. The Intriguing Obsession time limit per test1 secondmemory limit per test256 megabytesinputstanda ...

  9. 【Codeforces 869 C The Intriguing Obsession】 组合数学 思维

    C. The Intriguing Obsession time limit per test1 second memory limit per test256 megabytes inputstan ...

最新文章

  1. 编写自己的SpringBoot-starter
  2. 电大在线计算机考试,最新电大《计算机》考试题.doc
  3. PostgreSQL的实践一:初识
  4. Java 并发:Executor ExecutorService ThreadPoolExecutor
  5. Visual Studio Team System 2008 Team Suite 简体中文正式版
  6. k8s挂载目录_拥抱云原生,如何将开源项目用k8s部署?
  7. 获得手机屏幕相关参数
  8. Linux tcp三次握手,解读TCP三次握手
  9. Android设备新型恶意软件,融合银行木马、键盘记录器和移动勒索软件等功能
  10. python 模拟登录验证码_Python模拟登陆 —— 征服验证码 3 CSDN
  11. 分享这些年来第三方支付业务的申请流程及详细方案
  12. 关于个人求职简历的一些见解
  13. 杨辉三角形算法php实现,PHP实现杨辉三角形
  14. python_大智慧SAR指标编写
  15. 文本文件(txt或者ttt格式)数据导入OpenGL中绘制花房子
  16. 【WiFi】hostapd 配置80M频宽某些信道启动失败问题分析及解决
  17. double值精确到小数点后两位
  18. 两个二层交换机,两个PC配置固定地址,查看MAC地址实验
  19. 什么是反射机制?反射机制有什么作用?
  20. 微信小程序上传文件报错: errMsg: “uploadFile:fail createUploadTask:fail invalid url“

热门文章

  1. 汇聚优质AR应用开发者,技术助力AR领域繁荣生态
  2. 51CTO.com 巅峰访谈:让远程接入访问变得更简单 更高效
  3. 京东双叠加神单漏洞券操作教程
  4. HTML代码格式化工具
  5. zabbix3.4接入微信报警
  6. Java中的自动向量化(SIMD)
  7. win10中查看wifi密码
  8. ARM GPU Mali底层架构
  9. 微信小程序支持windows PC版了
  10. linux乌班图做服务器,使用 Ubuntu 16.04 搭建全能服务器