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条分割线,第一条分割线的前面和最后一条分割线的后 ...
随机推荐
- 求幂运算、多项式乘法及Horner法则的应用
一,两种不同的求幂运算 求解x^n(x 的 n 次方) ①使用递归,代码如下: private static long pow(int x, int n){ if(n == 0) return 1; ...
- oozie JAVA Client 编程提交作业
1,eclipse环境搭建 在eclipse中新建一个JAVA工程,导入必要的依赖包,目前用到的有: 其次编写JAVA 程序提交Oozie作业,这里可参考:oozie官方参考文档 在运行提交程序前,首 ...
- bootstrap-table前端修改数据
使用bootstrap-table显示数据,后台传回数据以后,可能需要对其做调整,如需要前端为数据添加单位 调整数据代码 $("#"+tableId).bootstrapTable ...
- RAC
RAC (Oracle网格计算技术) 编辑 Oracle RAC是Oracle Real Application Cluster的简写,官方中文文档一般翻译为“真正应用集群”,它一般有两台或者两台以上 ...
- ROS安装与卸载
1 版本选择 ROS 虽说也叫操作系统,但它是寄生在 LINUX 操作系统之下的,所以要求大兄弟你的电脑里至少要先有一个 LINUX 操作系统. 而对 ROS 兼容性最好的当属 Ubuntu 操作系统 ...
- Linux文件系统1---概述
1.引言 本文所述关于文件管理的系列文章主要是对陈莉君老师所讲述的文件系统管理知识讲座的整理.Linux可以支持不同的文件系统,它源于unix文件系统,也是unix文件系统的一大特色. 本文主要先 ...
- win7下出现读不到移动硬盘的解决办法
很多电脑会出现移动硬盘读不到,或者 读到部分盘的情况,那么下面我就为大家来一一解决这些情况: 方法一: 最常见的是硬盘供电不足导致 ,要么换一个硬盘盒子,要么给硬盘一个外加电源即可方法二: ...
- ES系列十六、集群配置和维护管理
一.修改配置文件 1.节点配置 1.vim elasticsearch.yml # ======================== Elasticsearch Configuration ===== ...
- mysql锁表与不锁表设置主从复制的方法
有时候MySQL主从同步不一致比较严重的时候,需要手动同步.先说说在锁表的情况下如何操作:以下是其简要过程 1.先对主库锁表FLUSH TABLES WITH READ LOCK; 2.备份数据mys ...
- oracle 回退表空间清理
1.查看已有表空间,找到回退表空间 SELECT * FROM DBA_TABLESPACES WHERE CONTENTS='UNDO' 2.创建新的回退表空间 create undo tables ...