noi.ac day5t1 count
分析
首先一个很重要的性质是每个数至少出现一次
所以只有一个数会出现两次
我们只需要求出n+1个数选k个数的方案数再减去重复的部分即可
重复部分于两个相同数中间的距离有关,详见代码
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int mod = 1e9+;
int p[];
inline int pw(int x,int p){
x%=mod;
int res=;
while(p){
if(p&)res=(long long)res*x%mod;
x=(long long)x*x%mod;
p>>=;
}
return res;
}
inline int c(int n,int m){
if(m>n)return ;
return (long long)p[n]*pw(p[m],mod-)%mod*pw(p[n-m],mod-)%mod;
}
int sum[],a[];
int main(){
int n,m,i,j,k,wh;
scanf("%d",&n);
for(i=;i<=n;i++){
scanf("%d",&a[i]);
if(sum[a[i]])wh=i-sum[a[i]];
sum[a[i]]=i;
}
p[]=p[]=;
for(i=;i<=n+;i++)p[i]=(long long)p[i-]*i%mod;
for(k=;k<=n+;k++)
printf("%d\n",(c(n+,k)-c(n-wh,k-)+mod)%mod);
return ;
}
noi.ac day5t1 count的更多相关文章
- NOI.AC NOIP模拟赛 第五场 游记
NOI.AC NOIP模拟赛 第五场 游记 count 题目大意: 长度为\(n+1(n\le10^5)\)的序列\(A\),其中的每个数都是不大于\(n\)的正整数,且\(n\)以内每个正整数至少出 ...
- SDOI2015 寻宝游戏 | noi.ac#460 tree
题目链接:戳我 可以知道,我们相当于是把有宝藏在的地方围了一个圈,求这个圈最小是多大. 显然按照dfs序来遍历是最小的. 那么我们就先来一遍dfs序列,并且预处理出来每个点到根的距离(这样我们就可用\ ...
- # NOI.AC省选赛 第五场T1 子集,与&最大值
NOI.AC省选赛 第五场T1 A. Mas的童年 题目链接 http://noi.ac/problem/309 思路 0x00 \(n^2\)的暴力挺简单的. ans=max(ans,xor[j-1 ...
- NOI.ac #31 MST DP、哈希
题目传送门:http://noi.ac/problem/31 一道思路好题考虑模拟$Kruskal$的加边方式,然后能够发现非最小生成树边只能在一个已经由边权更小的边连成的连通块中,而树边一定会让两个 ...
- NOI.AC NOIP模拟赛 第六场 游记
NOI.AC NOIP模拟赛 第六场 游记 queen 题目大意: 在一个\(n\times n(n\le10^5)\)的棋盘上,放有\(m(m\le10^5)\)个皇后,其中每一个皇后都可以向上.下 ...
- NOI.AC NOIP模拟赛 第二场 补记
NOI.AC NOIP模拟赛 第二场 补记 palindrome 题目大意: 同[CEOI2017]Palindromic Partitions string 同[TC11326]Impossible ...
- NOI.AC NOIP模拟赛 第一场 补记
NOI.AC NOIP模拟赛 第一场 补记 candy 题目大意: 有两个超市,每个超市有\(n(n\le10^5)\)个糖,每个糖\(W\)元.每颗糖有一个愉悦度,其中,第一家商店中的第\(i\)颗 ...
- NOI.AC NOIP模拟赛 第四场 补记
NOI.AC NOIP模拟赛 第四场 补记 子图 题目大意: 一张\(n(n\le5\times10^5)\)个点,\(m(m\le5\times10^5)\)条边的无向图.删去第\(i\)条边需要\ ...
- NOI.AC NOIP模拟赛 第三场 补记
NOI.AC NOIP模拟赛 第三场 补记 列队 题目大意: 给定一个\(n\times m(n,m\le1000)\)的矩阵,每个格子上有一个数\(w_{i,j}\).保证\(w_{i,j}\)互不 ...
随机推荐
- kylin_学习_02_kylin使用教程
一. 二.参考资料 1.kylin从入门到实战:实际案例
- git教程5-查看关系图与no fast forward融合
1.每一个提交相当于一个版本,版本都有版本号与之对应.通常通过git commit -m "name"为每次提交命名. 2.融合:即将次分支的最后一个版本添加到主分支上.当融合冲突 ...
- XML的语法
XML的语法 文档声明: 写法 <?xml version="1.0" ?> 文档声明必须出现在xml文件的第一行和第一列的位置 属性: version="1 ...
- poj2336
题目大意:一个船要把n个车渡过河 船最多载m辆车 把车运过去需要t的时间 回来也要t的时间 给定n辆车依次到河边的时间 求最短运送时间 还有最短跑几趟 一维dp 可以直接d运送时间 dp[i] ...
- dbca 快速健建库
[oracle@e0946877f272 ~]$ dbca -silent -createDatabase -templateName $ORACLE_HOME/assistants/dbca/tem ...
- New Year and Counting Cards
Your friend has n cards. You know that each card has a lowercase English letter on one side and a di ...
- Phone numbers
Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, ...
- python 编码拓展,小数据池,
编码拓展: 1.在所有类型的编码中,编码的二进制互不识别, 2.在传输的过程中不能是万国码的二进制解码传输, 因此将unicode变为utf - 8或者变成gbk编码尤为重要; 利用encode编码为 ...
- linux下查找命令两则
由于本人不会阅读man手册,因此需要几下两个常用的查找命令: (1)在某个目录及其子目录查找某个文件并打印完整路径: find ./ -name "assertions.h" -e ...
- 为什么很多公司招聘前端开发要求有 Linux / Unix 下的开发经验?
知乎: http://www.zhihu.com/question/19666395