zoukankan      html  css  js  c++  java
  • 【CF Round 439 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 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.

    【翻译】给出三种颜色的点的数目a,b,c,现在连边建图,要求:同种颜色点之间距离大于等于3(无法通达也可以),求构图方案数。

    题解:

          ①关键结论是两个颜色点的连边和另一种颜色无关。

          ②直接对两种颜色dp:

               设f[i][j]表示有i个1号颜色的点,j个2号颜色的点的构图方案数。

               转移来源表示新加入的2颜色的点是否连边:
               f[i][j]=f[i][j-1]+f[i-1][j-1]*i

          ③最终答案:f[a][b]*f[a][c]*f[b][c]

    #define M 998244353
    #define ll long long
    #include<bits/stdc++.h> 
    #define go(i,a,b) for(int i=a;i<=b;i++)
    const int N=5003;
    ll f[N][N];
    int a,b,c,n;
    int main()
    {	
    	scanf("%d%d%d",&a,&b,&c);
    	n=std::max(a,std::max(b,c));
    	go(i,1,n)f[i][0]=f[0][i]=1;f[0][0]=1;
    	go(i,1,n)go(j,1,n)f[i][j]=(f[i][j-1]+f[i-1][j-1]*i)%M;
    	printf("%d",((f[a][b]*f[b][c])%M*f[a][c])%M);return 0;
    }//Paul_Guderian
    

    寻找生命的意义真的并不容易,

    那是件辛酸而伟大的事情。——————汪峰《改变》

  • 相关阅读:
    【TFLSnoi李志帅】第⑥篇文章---排序
    【TFLSnoi李志帅】第⑤篇文章--递推算法经典例题
    【TFLSnoi李志帅】第四篇文章---高精度加法
    【TFLSnoi李志帅】第三篇文章
    【TFLSnoi李志帅】第三篇文章---问题记录
    【TFLSnoi李志帅】第一篇文章
    为什么成功引入jquery后,效果无法生效
    到底classpath指向哪里
    05-配置web.xml
    04-配置事务管理
  • 原文地址:https://www.cnblogs.com/Damitu/p/7658383.html
Copyright © 2011-2022 走看看