任意门:https://nanti.jisuanke.com/t/20750

J - LOL

5 friends play LOL together . Every one should BAN one character and PICK one character . The enemy should BAN 55 characters and PICK 55 characters . All these 2020 heroes must be different .

Every one can BAN any heroes by his personal washes . But he can only PICK heroes which he has bought .

Suppose the enemy can PICK or BAN any heroes. How many different ways are there satisfying the conditions?

For example , a valid way is :

Player 11 : picks hero 11, bans hero 22

Player 22 : picks hero 33, bans hero 44

Player 33 : picks hero 5, bans hero 66

Player 44 : picks hero 77, bans hero 88

Player 55 : picks hero 99, bans hero 1010

Enemies pick heroes 11,12,13,14,1511,12,13,14,15 , ban heroes 16,17,18,19,2016,17,18,19,20 .

Input

The input contains multiple test cases.(No more than 2020)

In each test case . there’s 55 strings S[1] \sim S[5]S[1]∼S[5] ,respectively whose lengths are 100100 , For the ii-th person if he has bought the jj-th hero, the jj-th character of S[i]S[i] is '11', or '00' if not. The total number of heroes is exactly 100100 .

Output

For each test case , print the answer mod 10000000071000000007 in a single line .

样例输入复制

0110011100011001001100011110001110001110001010010111111110101010010011010000110100011001001111101011
1000111101111110110100001101001101010001111001001011110001111110101000011101000001011100001001011010
0100101100011110011100110110011100111100010010011001111110101111111000000110001110000110001100001110
1110010101010001000110100011101010001010000110001111111110101010000000001111001110110101110000010011
1000010011111110001101100000101001110100011000111010011111110110111010011111010110101111011111011011

样例输出复制

515649254

题意概括:

五个二进制数代表我方 5 人所拥有的英雄,0为没有,1为有。

敌方5人什么英雄都有,问有多少种 Ban Pick方案。

每人都可以选一个自己拥有的英雄和 ban 掉任何一个英雄,最后选的和禁止掉的20个英雄都不相同。

解题思路:

暴力枚举我方选英雄的方案

敌方选英雄的方案为 A(95, 5)

我方禁英雄的方案为 C(90, 5)

敌方禁英雄的方案为 C(85,5)

关于暴力的优化和剪枝:

如果是传统暴力枚举每个人选不同英雄的方案,需要五层 for(0, 100) 循环,TL!

优化只枚举前四个人的方案, 第五个能选的英雄只能是前面没有选的,缩小了一层循环。

关于剪枝 前面选过的不要选咯

AC code:

 #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
const int mod = 1e9+;
const int MAXN = ; char a[MAXN], b[MAXN], c[MAXN], d[MAXN], e[MAXN];
LL A(LL N, LL R)
{
LL sum = ;
for(int i = ; i < R; i++)
sum *= N-i;
return sum;
} LL C(LL N, LL R)
{
LL sum = ;
for(int i = ; i <= R; i++)
sum = sum* (N+-i)/i;
return sum;
} int main()
{
while(~scanf("%s%s%s%s%s", a, b, c, d, e)){
int len = ;
for(int i = ; i < ; i++){
if(e[i] == '') len++;
}
LL ans = ;
for(int i = ; i < ; i++){
if(a[i] == '') continue;
for(int j = ; j < ; j++){
if(b[j] == '' || j == i) continue;
for(int k = ; k < ; k++){
if(c[k] == '' || k == i || k == j) continue;
for(int p = ; p < ; p++){
if(d[p] == '' || p == i || p == j || p == k) continue;
int res = len;
if(e[i] == '') res--;
if(e[j] == '') res--;
if(e[k] == '') res--;
if(e[p] == '') res--;
if(res>=) ans+=res;
}
}
}
}
ans = ans*A(, )%mod*C(, )%mod*C(, )%mod;
printf("%lld\n", ans);
}
return ;
}

ACM-ICPC 2017 Asia Xi'an J LOL 【暴力 && 排列组合】的更多相关文章

  1. 计蒜客 A1607 UVALive 8512 [ACM-ICPC 2017 Asia Xi'an]XOR

    ICPC官网题面假的,要下载PDF,点了提交还找不到结果在哪看(我没找到),用VJ交还直接return 0;也能AC 计蒜客题面 这个好 Time limit 3000 ms OS Linux 题目来 ...

  2. ACM-ICPC 2017 Asia Xi'an

    ACM-ICPC 2017 Asia Xi'an Solved A B C D E F G H I J K 7/11 O O Ø O O ? O O O for passing during the ...

  3. ACM ICPC 2017 Warmup Contest 9 I

    I. Older Brother Your older brother is an amateur mathematician with lots of experience. However, hi ...

  4. ACM ICPC 2017 Warmup Contest 9 L

    L. Sticky Situation While on summer camp, you are playing a game of hide-and-seek in the forest. You ...

  5. ACM-ICPC 2017 Asia Xi'an A XOR (线性基+线段树思想)

    题目链接 题意;给个数组,每次询问一个区间你可以挑任意个数的数字异或和 然后在或上k的最大值 题解:线性基不知道的先看这个,一个线性基可以log的求最大值把对应去区间的线性基求出来然后用线段树维护线性 ...

  6. ACM ICPC 2017 Warmup Contest 1 D

    Daydreaming Stockbroker Gina Reed, the famous stockbroker, is having a slow day at work, and between ...

  7. 2017 ACM ICPC Asia Regional - Daejeon

    2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...

  8. 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest

    2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...

  9. 2017 ACM/ICPC Asia Regional Qingdao Online

    Apple Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submi ...

随机推荐

  1. Open Closed Principle(OCP)开闭原则

    面向对象的最基本原则 Software entites like classes,modules and functions should be open for extension but cloa ...

  2. (转) sync命令

    sync sync命令 sync命令用于强制被改变的内容立刻写入磁盘,更新超块信息. 在Linux/Unix系统中,在文件或数据处理过程中一般先放到内存缓冲区中,等到适当的时候再写入磁盘,以提高系统的 ...

  3. merchantInfo.properties配置文件

    p1_MerId=10001126856 keyValue=69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl callback= ...

  4. 通过宏定义将__declspec(dllexport)与__declspec(dllimport)的转化,实现库代码和使用代码使用同一份头文件

    我们知道,在VC编程中,如果要编译成动态链接库,需要将函数.变量.类等导出,这时使用__declspec(dllexport).使用动态链接库时,需要在声明的时候有使用__declspec(dllim ...

  5. web部署启动或者运行报错查看日志寻找问题方法

    今天运行一个项目,启动报错,查看日志,只看到了前半段错误日志,根据前半段错误日志差查找原因,找了两个小时,也没有解决掉,最后根据后半段错误日志十分钟定位错误,给解决了,以后出现问题不能急躁,查看完成的 ...

  6. CTSC/APIO2018 游记

    狗牌滚粗选手,此博客证明我去过...... CTSC 消失的源代码与消失的分数...... 我也不知道发生了什么....... APIO 旁边两位小哥太强了,心态完全炸裂,最后也滚粗了...... 回 ...

  7. 修改Linux时区的2种办法

    由于Azure 上所有的服务时间都采用了 UTC 时间.UTC 时间比中国时间晚 8 个小时,该如何按照自己的需要来进行修改呢,下面提供2种办法以供参考: 1.修改 /etc/localtime 文件 ...

  8. Baseball Game

    You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 ...

  9. 【Linux】安装Nginx

    注:转自https://www.cnblogs.com/hdnav/p/7941165.html 安装所需环境 Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Window ...

  10. 1094 FBI树

    1094 FBI树 2004年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver       题目描述 Description 我们可以把由“ ...