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 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 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.

/*
* @Author: LyuC
* @Date: 2017-10-06 21:23:13
* @Last Modified by: LyuC
* @Last Modified time: 2017-10-06 23:34:22
*/
#include <bits/stdc++.h> #define LL unsigned long long
#define MOD 998244353
#define N 5005
using namespace std; LL a,b,c;
LL ab,ac,bc;
LL mi,ma; //O(n)的算法
LL F[N], Finv[N], inv[N];//F是阶乘,Finv是逆元的阶乘
void init(){
inv[] = ;
for(int i = ; i < N; i ++){
inv[i] = (MOD - MOD / i) * 1ll * inv[MOD % i] % MOD;
}
F[] = Finv[] = ;
for(int i = ; i < N; i ++){
F[i] = F[i-] * 1ll * i % MOD;
Finv[i] = Finv[i-] * 1ll * inv[i] % MOD;
}
}
LL Comb(LL n, LL m){//comb(n, m)就是C(n, m)
if(m < || m > n) return ;
return F[n] * 1ll * Finv[n - m] % MOD * Finv[m] % MOD;
} int main(){
// freopen("in.txt","r",stdin);
init();
ab=;
ac=;
bc=;
cin>>a>>b>>c;
//ab;
mi=min(a,b);
ma=max(a,b);
for(int i=;i<=mi;i++){
ab=(ab+Comb(mi,i)%MOD*Comb(ma,i)%MOD*F[i]%MOD)%MOD;
}
//ac;
mi=min(a,c);
ma=max(a,c);
for(int i=;i<=mi;i++){
ac=(ac+Comb(mi,i)%MOD*Comb(ma,i)%MOD*F[i]%MOD)%MOD;
}
//bc;
mi=min(b,c);
ma=max(b,c);
for(int i=;i<=mi;i++){
bc=(bc+Comb(mi,i)%MOD*Comb(ma,i)%MOD*F[i]%MOD)%MOD;
}
cout<<ab*ac%MOD*bc%MOD<<endl;
return ;
}

code forces 439 C. The Intriguing Obsession的更多相关文章

  1. Codeforces Round #439 C. The Intriguing Obsession

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

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

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

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

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

  4. 思维题--code forces round# 551 div.2

    思维题--code forces round# 551 div.2 题目 D. Serval and Rooted Tree time limit per test 2 seconds memory ...

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

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

  6. The Intriguing Obsession

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

  7. Code Forces 796C Bank Hacking(贪心)

    Code Forces 796C Bank Hacking 题目大意 给一棵树,有\(n\)个点,\(n-1\)条边,现在让你决策出一个点作为起点,去掉这个点,然后这个点连接的所有点权值+=1,然后再 ...

  8. Code Forces 833 A The Meaningless Game(思维,数学)

    Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...

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

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

随机推荐

  1. 翻译 | 玩转 React 表单 —— 受控组件详解

    原文地址:React.js Forms: Controlled Components 原文作者:Loren Stewart 译者:小 B0Y 校对者:珂珂君 本文涵盖以下受控组件: 文本输入框 数字输 ...

  2. TCP/IP(一)之初识计算机网络

    前言 在一段时间里,都很想知道一台电脑怎么跟另一台电脑通信的,我发送一个qq给女朋友,怎么准确的发送过去的,又是怎么接受消息的. 接下来一段时间给大家慢慢分享关于计算机网络的相关知识. 一.局域网.广 ...

  3. (一) .net core 2.0 初体验

    1..net core 2.0环境 .net core 下载地址:https://www.microsoft.com/net/core#windowscmd 问题一:提示[Failed to load ...

  4. POJ(1195)(单点修改,区间查询)(二维)

    题目大意 给定一个N*N的网格,刚开始每个网格的值都是0,接下来会对这些网格进行操作,有一下两种操作: 1."X Y A"对网格C[x][y]增加A 2."L B R T ...

  5. 计蒜客 2017 NOIP 提高组模拟赛(四)Day1 T2 小X的密室

    https://nanti.jisuanke.com/t/17323 小 X 正困在一个密室里,他希望尽快逃出密室. 密室中有 N 个房间,初始时,小 X 在 1号房间,而出口在 N号房间. 密室的每 ...

  6. 通过JQuery实现Ajax代码

    今天早上遇到了这个问题,结果我写的顺序是惨不忍睹啊,所有现在留个模版以示标准. $(function(){ $.ajax({ url : "Servlet", //传地址 type ...

  7. #云栖大会# 移动安全专场——APP加固新方向(演讲速记)

    主持人导语: 近些年来,移动APP数量呈现爆炸式的增长,黑产也从原来的PC端转移到了移动端,伴随而来的逆向攻击手段也越来越高明.在解决加固产品容易被脱壳的方案中,代码混淆技术是对抗逆向攻击最有效的方式 ...

  8. selenium 调用键盘按键

    1.想要调用键盘按键操作需要引入keys包: from selenium.webdriver.common.keys import keys 通过send_keys() 调用按键 send_keys( ...

  9. winPcap编程之不用回调方法捕获数据包(五 转)

    这一次要分析的实例程序跟上一讲非常类似(“打开适配器并捕获数据包”),略微不同的一点是本次将pcap_loop()函数替换成了pcap_next_ex()函数.本节的重点也就是说一下这两个函数之间的差 ...

  10. vb6.0的各种SHELL,CMD内部命令、外部命令、SHELL任意文件

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (B ...