题意:给你三种不同颜色的点,每种若干(小于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. VS2008 快捷键大全

    转载自 https://www.cnblogs.com/likebeta/archive/2013/02/20/2919224.html Ctrl+E,D ----             格式化全部 ...

  2. spring(三、spring中的eheche缓存、redis使用)

    spring(三.spring中的eheche缓存.redis使用) 本文主要介绍为什么要构建ehcache+redis两级缓存?以及在实战中如何实现?思考如何配置缓存策略更合适?这样的方案可能遗留什 ...

  3. webpack初步学习

    https://segmentfault.com/a/1190000006178770 该篇文章足够webpack入门的学习了,对webpack有个初步的了解和认识.

  4. Vue遇到的问题

      1.<a v-bind:[attributeName]="url"> ... </a> 报错,原因 attributeName应该属于关键字,不能用 2 ...

  5. js layer.js

    var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); 关闭弹出页 全屏弹出页面 layer.o ...

  6. 全志A33 lichee 开发板 Linux中断编程原理说明

    开发平台 * 芯灵思SinlinxA33开发板 淘宝店铺: https://sinlinx.taobao.com/ 嵌入式linux 开发板交流 QQ:641395230 本节实验目标实现按键触发中断 ...

  7. [JAVA]为什么==和equals总让新手迷惑? 详解 关系操作符 == 和 equals

    关系操作符==和 类的equals方法都可以用来比较两个类是否相同,但实际用起来却经常产生令JAVA新手迷惑的结果. 先看一段示例代码: public class HelloWorld { publi ...

  8. Hadoop 管理工具HUE配置-Hive配置

    1 前言 首先要配置好Hive,可以参见:http://www.cnblogs.com/liuchangchun/p/4761730.html 2 hive配置 找到beeswax标签,不叫hive, ...

  9. 部署MySQL自动化运维工具inception+archer

    ***************************************************************************部署MySQL自动化运维工具inception+a ...

  10. 内训--2小时 Word精髓

    企业内部使用Word最常见就是用来写产品手册与合同,产品手册是书版(即可以出版,与买到的书类似),合同重点是修订.Word的精髓在于样式,或者说在企业办公使用,学会样式就可以了.什么域.宏.VBA几乎 ...