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

Examples
Input
  1. 1 1 1
Output
  1. 8
Input
  1. 1 2 2
Output
  1. 63
Input
  1. 1 3 5
Output
  1. 3264
Input
  1. 6 2 9
Output
  1. 813023575
  2. 思路:从第一个样例来看点与点之间是可以不连通的,而且题目要求同色点的最短路大于等于3,也就是说两个同色的点不能连到同一点
        上去。仔细想想,每个点是不影响整体的合法性的,也就是说如果整体是合法的,去掉其中一个点以及它连的线是合法的,加上一
        个合法连线的点也是合法的。所以我们可以算出每种颜色互相连的方案数然后乘起来就行了。
        这里算方案数的时候,是取两种颜色的点的个数x,y的最小值mi,然后i0mians+=C[x][i]*C[y][i]*阶乘(i
        相当于是一个排列组合吧23333.
  3. 代码:
    #include<iostream>
    #include<algorithm>
    using namespace std;
  4. const int mod=998244353;
    const int maxn=5005;
    int C[maxn][maxn],f[maxn],a,b,c;
  5. 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;
            }
        }
    }
  6. 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. supervisord.conf

    ; Sample supervisor config file.;; For more information on the config file, please see:; http://supe ...

  2. matlab学习(4) any 和cellfun用法

    1.对于向量来说,只要包含非0元素,则返回为1: 2.对于矩阵来说,any(X)依次判断X的每一列是否为ture,返回一个含0或1的向量. 3.any(X,DIM)对X的第DIM维操作, DIM=1即 ...

  3. Python全栈之路----类型转换

    显式转换 int(x [,base]) ⇒ 将x转换为一个十进制的整数 long(x [,base]) ⇒ 将x转换为一个十进制的长整数 float(x) ⇒ 将x转换为一个浮点数 str(objec ...

  4. PTA——完全数

    PTA 7-45 找完数 网友“云上明月”的程序: #include<stdio.h> int isPerfect(int num); int main() { ; int maxFact ...

  5. I think I need a boat house

    I think I need a boat house. Fred Mapper is considering purchasing some land in Louisiana to build h ...

  6. [CSL 的字符串][栈,模拟]

    链接:https://ac.nowcoder.com/acm/contest/551/D来源:牛客网题目描述 CSL 以前不会字符串算法,经过一年的训练,他还是不会……于是他打算向你求助. 给定一个字 ...

  7. webpack的知识内容

    webpack的构建工具: 浏览器的兼容性? 转换ES6语法: 转化JSX: css

  8. Day 09 函数基础

    函数初级 简介 # 函数是一系列代码的集合,用来完成某项特定的功能 优点 '''1. 避免代码的冗余2. 让程序代码结构更加清晰3. 让代码具有复用性,便于维护''' 函数四部分 '''1. 函数名: ...

  9. 第3章 Vim使用笔记

    3.1 vi使用map自定义快捷方式 [想要永久保存定义的快捷键在-/.vimrc[进入root后才能看到~/.vimrc文件]中编辑保存即可!] set nu 输入下列命令[:map <spe ...

  10. mongodb集群配置分片集群

    测试环境 操作系统:CentOS 7.2 最小化安装 主服务器IP地址:192.168.197.21 mongo01 从服务器IP地址:192.168.197.22 mongo02 从服务器IP地址: ...