题意:给你三种不同颜色的点,每种若干(小于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. selenium-java,selenium版本和火狐浏览器版本对应关系

    selenium3.5.0,firefox57,geckodriver-v0.19.1

  2. 2018 vue前端面试题

    1.active-class是哪个组件的属性?嵌套路由怎么定义?答:vue-router模块的router-link组件. 2.怎么定义vue-router的动态路由?怎么获取传过来的动态参数? 答: ...

  3. JAVA第八次作业

    JAVA第八次作业 (一)学习总结 1.用思维导图对本周的学习内容进行总结 参考资料: XMind. 2.通过实验内容中的具体实例说明在执行executeUpdate()方法和executeQuery ...

  4. 初识vue小结

    初识vue 大家都那么热爱他一定有原因,我也特想了解. 我来咯, 首先用vue开发版,用一个标签在head中插入,script标签src属性引入vue文件,就像jquey一样在script,但是放在h ...

  5. day02python入门

    今日概要 解释器环境安装 输出 python试执行 数据类型 变量 输入 注释 条件判断 循环 占位符 数据类型转换 1. 环境的安装 python解释器 py2: Python2.7 (老版本) . ...

  6. 小程序通过background-image设置背景图片

    微信小程序通过background-image设置背景:只支持线上图片和base64图片,不支持本地图片:base64图片设置步骤如下: 1.在网站http://imgbase64.duoshiton ...

  7. MySQL 命令(导出数据):mysqldump

    官方网址:https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html

  8. 1.4 安装Linux系统

    按F2进入BIOS,设置通过[CD/ROM]启动,如果是真实计算机,安装完后还需要重新设置为[硬盘启动] 设置分区如下图所示:

  9. python3中的编码

    python2字符串编码存在的问题: 使用 ASCII 码作为默认编码方式,对中文处理不友好 把字符串分为 unicode 和 str 两种类型,将unicode作为唯一内码,误导开发者 python ...

  10. ubuntu下的Nessus插件更新

    00x1: 记录下nessus插件离线更新,免得每次度娘我Nessus是放在虚拟机里面. 00x2: nessus 插件更新地址: https://plugins.nessus.org/v2/offl ...