题意:给你三种不同颜色的点,每种若干(小于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. 创建Java多线程的两种方式和线程异常

    一.使用多线程的两种方法  使用多线程的两种方法有:继承Thread类和实现runable接口. 二.继承Thread类 来看一下thread类的源代码: class Thread implement ...

  2. python 转义字符 html 爬虫

    用python的requests包 抓取某些网页时,返回的html中,一些字段含有一些 转义字符 \\\\\\\ 这些转义字符给我们后期处理带来一些麻烦, 比方说 运行js等 python用print ...

  3. linux基础之LSB定义的常用目录详解

    Linux基础之LSB定义的基本目录详解 1.LSB中FHS(Filesystem Hierarchy Standard)定义的一些文件 /boot:主要是存放引导文件的目录,比如内核文件(vmlin ...

  4. 使用Log4net 日志系统

    官方文档 http://logging.apache.org/log4net/release/config-examples.html C# 项目中直接使用nuget,下载Apache的log4net ...

  5. spring-boot入门总结

    1.org.springframework.web.bind.annotation不存在 错误的pom.xml <dependency> <groupId>org.spring ...

  6. nginx添加一个站点

    server { listen ; server_name demo.abc.com ; root /Users/pa200318/demo.cp.com/trunk; index index.php ...

  7. esxi5 的tart命令使用注意点

    esxi5.0 注意tar命令参数使用和centos6稍微有点不一样,注意下 注意需要把-f参数单独分离出来,紧接着文件.   而不能和cz命令一起用 ~ # touch abc.txt ~ # ec ...

  8. Java注解总结2

    注解是Java元数据,可以理解成代码的标签,正确使用能极大的简化代码的编写逻辑,在各种框架代码中使用也越来越多. 一.注解的应用场景 生成doc文档: 编译器类型格式检查: 运行时处理如注入依赖等 二 ...

  9. set-----》集合

    1.set 是无序  不重复的序列 2.创建 list = [] dic = {"k1":123} set = {"123","333"}  ...

  10. startup.bat 一闪而过解决方案

    原文地址:http://blog.csdn.net/stypace/article/details/38083581 启动tomcat时cmd窗口一闪而过解决方法. 注: 我这边只是配置了环境变量就o ...