Codeforces 757 C Felicity is Coming!
题目大意:有n个训练营,m种宠物,每个训练营里里面有gi 个宠物,现在每只宠物都要完成一次进化,种类
相同的宠物进化之后,种类还是相同,种类不同的宠物不能进化成相同种类,且要求所有宠物进化之后,每个
训练营各个种类的宠物数量不变。
思维题
思路:我们不能一个一个训练营考虑,我们要考虑不同种类宠物的情况,我们统计每种宠物出现在那个训练营
里面且出现几次,统计结果完全一样的宠物种类分为一堆,这一堆里面的宠物如果有x个,则这堆的贡献为x!
将所有堆得结果想乘就是结果。
原来将vector<int> vec[ N ] 排序,sort(vec,vec+N),是每个按字典序排序,学到了。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+;
const ll mod=1e9+;
int n,m;
ll f[N];
vector<int> cnt[N];
int main()
{
cin>>n>>m;
f[]=;
for(ll i=;i<=m;i++) f[i]=(f[i-]*i)%mod;
for(int i=;i<=n;i++)
{
int g; scanf("%d",&g);
while(g--)
{
int w; scanf("%d",&w);
cnt[w].push_back(i);
}
}
sort(cnt+,cnt++m);
int c=;
ll ans=;
for(int i=;i<=m;i++)
{
if(cnt[i]==cnt[i-])
{
c++;
if(i==m) ans=(ans*f[c])%mod;
}
else
{
ans=(ans*f[c])%mod;
c=;
}
}
cout<<ans<<endl;
return ;
}
Codeforces 757 C Felicity is Coming!的更多相关文章
- Codeforces 757 D. Felicity's Big Secret Revealed 状压DP
D. Felicity's Big Secret Revealed The gym leaders were fascinated by the evolutions which took pla ...
- 【codeforces 757C】Felicity is Coming!
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 757D】Felicity's Big Secret Revealed
[题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所 ...
- Codeforces 757 E Bash Plays with Functions
Discription Bash got tired on his journey to become the greatest Pokemon master. So he decides to ta ...
- Codeforces 757 F Team Rocket Rises Again
Discription It's the turn of the year, so Bash wants to send presents to his friends. There are n ci ...
- Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)D. Felicity's Big Secret Revealed
题目连接:http://codeforces.com/contest/757/problem/D D. Felicity's Big Secret Revealed time limit per te ...
- Codeforces 757C. Felicity is Coming!
C. Felicity is Coming! time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round #391 C. Felicity is Coming!
题目链接 http://codeforces.com/contest/757/problem/C 题意:给你n组数范围在1-m,可进行变换f(x)=y,就是将所有的x全变成y,最后 要满足变化后每组数 ...
- Codeforces 757D - Felicity's Big Secret Revealed
757D - Felicity's Big Secret Revealed 题目大意:给你一串有n(n<=75)个0或1组成的串,让你划最多n+1条分割线,第一条分割线的前面和最后一条分割线的后 ...
随机推荐
- chart 数据 图表插件
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js">< ...
- 第5月第6天 NSOperation isConcurrent category同名覆盖
1. @implementation AFURLConnectionOperation ... - (BOOL)isConcurrent { return YES; } NSOperation调用st ...
- transition,过渡效果
语法: transtion:property time change-speed delay. 人话就是:属性(property )在多少秒内(time )通过什么样的速度(change-speed) ...
- 一套oracle的练习题
create table student( sno varchar2(10) primary key, sname varchar2(20), sage number(2), ssex varchar ...
- C++学习4-面向对象编程基础(面向对象概念,定义类,定义对象)
什么是面向对象? 在软件的设计过程中的两种方式: 把程序按照算法的执行步骤来拆解,一步步实现,这是面向过程编程: 把程序按照现实世界的理解,分成不同对象,通过多个对象之间的相互作用,来完成程序的最终功 ...
- python中的魔法参数:*args和**kwargs
python中的魔法参数:*args和**kwargs def foo(*args, **kwargs):print 'args = ', argsprint 'kwargs = ', kwargsp ...
- Python 3.x 格式化输出字符串 % & format 笔记
Python 3.x 格式化输出字符串 % & format 笔记 python格式化字符串有%和{}两种 字符串格式控制符. 字符串输入数据格式类型(%格式操作符号) %%百分号标记 %c字 ...
- k-means 图像分割
经典的无监督聚类算法,不多说,上代码. import numpy as np import pandas as pd import copy import matplotlib.pyplot as p ...
- caffe-win10-cifar10另
上一篇主要以bat形式实现了leveldb形式的cifar10,因为对于shell脚本不甚熟悉,所以这次专门利用.sh调用来实现lmdb形式的cifar10. 1.下载数据 同上一篇. 2.数据转换和 ...
- ReLu、LeakyRelu、PReLu(转载)
转载链接:http://blog.csdn.net/cham_3/article/details/56049205