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

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

思路:从第一个样例来看点与点之间是可以不连通的,而且题目要求同色点的最短路大于等于3,也就是说两个同色的点不能连到同一点
    上去。仔细想想,每个点是不影响整体的合法性的,也就是说如果整体是合法的,去掉其中一个点以及它连的线是合法的,加上一
    个合法连线的点也是合法的。所以我们可以算出每种颜色互相连的方案数然后乘起来就行了。
    这里算方案数的时候,是取两种颜色的点的个数x,y的最小值mi,然后i从0到mi,ans+=C[x][i]*C[y][i]*阶乘(i)
    相当于是一个排列组合吧23333. 代码:
#include<iostream>
#include<algorithm>
using namespace std; const int mod=998244353;
const int maxn=5005;
int C[maxn][maxn],f[maxn],a,b,c; void init(){
    f[0]=1;
    for(int i=1;i<=maxn;i++){
        f[i]=1LL*f[i-1]*i%mod;
        C[i][0]=1;
    }
    C[0][0]=1;
    for(int i=1;i<=maxn;i++){
        C[i][i]=1;
        for(int j=1;j<i;j++){
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
        }
    }
} int solve(int x,int y){
    int mi=min(x,y),ans=0;
    for(int i=0;i<=mi;i++){
        ans=(ans+((1LL*C[x][i]*C[y][i])%mod*f[i])%mod)%mod;
    }
    return ans;
}
int main(){
    init();
    cin>>a>>b>>c;
    int ans1=solve(a,b),ans2=solve(a,c),ans3=solve(b,c);
    int sum=(((1LL*ans1*ans2)%mod)*ans3)%mod;
    cout<<sum<<endl;
    return 0;
}

Codeforces Round #439 C. The Intriguing Obsession的更多相关文章

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

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

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

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

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

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

  4. Codeforces Round #439 (Div. 2)

    A. The Artful Expedient 题目链接:http://codeforces.com/contest/869/problem/A 题目意思:给你两个数列,各包含n个数,现在让你从上下两 ...

  5. Codeforces Round #439 (Div. 2) C DP(图论)

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

  6. code forces 439 C. The Intriguing Obsession

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

  7. Codeforces Round #439 (Div. 2) A B C

    强哉qls,这场div2竟是其出的!!! A. The Artful Expedient 暴力 ^ ,判断是否出现,有大佬根据亦或的性质推出 Karen 必赢,太强啦23333333333333. # ...

  8. Codeforces Round #439 (Div. 2) 题解

    题目链接  Round 439 div2 就做了两道题TAT 开场看C题就不会 然后想了好久才想到. 三种颜色挑出两种算方案数其实是独立的,于是就可以乘起来了. E题想了一会有了思路,然后YY出了一种 ...

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

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

随机推荐

  1. mybatis插入数据后返回对象id

    1.插入的为对象,成功插入后,会返回到指定的字段id中,@Options(useGeneratedKeys=true,keyColumn="id").

  2. 《DSP using MATLAB》Problem 7.3

  3. 依据Axis2官网的高速入门英文文档总结

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/ksdb0468473/article/details/29918027 首先在Eclipse中创建一 ...

  4. 解决 windows下安装Anaconda后python pip不可用的情况

    在windows系统下通过安装Anaconda的方式安装的python使用中发现不能再通过pip安装python包.只能通过conda install packname 的方法,导致很多conda不支 ...

  5. [C#]如何将 string 安全地转换为 int

    当遇到string向int类型转换时会遇到以下问题: 1.字符串非数字格式 2.字符串描述的不是int型 3.转换后越界 这些情况都需要用try catch来捕获异常并处理 安全简单的转换可以用 In ...

  6. Maven+Spirng+Mybatis+CXF搭建WebService服务

    https://jingyan.baidu.com/article/39810a23b1de2fb637fda66c.html

  7. 一个基于typelist的typemap

    前面的typelist的e一个小扩展,http://www.cnblogs.com/flytrace/p/3551414.html. 可以插入pair<key_type, value_type& ...

  8. VUE打包上线优化

    1.将vue vue-router vuex 尽量使用CDN externals: { 'vue':'Vue', 'vue-router':'VueRouter', 'vuex':'Vuex', 'a ...

  9. PCLVisualizer可视化类

    PCLVisualizer可视化类 转载自 http://www.cnblogs.com/li-yao7758258/p/6445127.html 如有疑问,请转至该网址留言询问 PCLVisuali ...

  10. Windows程序设计_21_Win32文件操作

    没什么新的内容,自己的练习代码,供大家点评. /* Windows系统编程--实例 1)复制文件 */ #define UNICODE //#define _UNICODE #include < ...