题目链接:http://arc077.contest.atcoder.jp/tasks/arc077_b

Time limit : 2sec / Memory limit : 256MB

Score : 600 points

Problem Statement

You are given an integer sequence of length n+1a1,a2,…,an+1, which consists of the n integers 1,…,n. It is known that each of the n integers 1,…,n appears at least once in this sequence.

For each integer k=1,…,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 109+7.

Notes

  • If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.

  • A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.

Constraints

  • 1≤n≤105
  • 1≤ain
  • Each of the integers 1,…,n appears in the sequence.
  • n and ai are integers.

Input

Input is given from Standard Input in the following format:

n
a1 a2 ... an+1

Output

Print n+1 lines. The k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 109+7.


Sample Input 1

Copy
3
1 2 1 3

Sample Output 1

Copy
3
5
4
1

There are three subsequences with length 11 and 2 and 3.

There are five subsequences with length 21,1 and 1,2 and 1,3 and 2,1 and 2,3.

There are four subsequences with length 31,1,3 and 1,2,1 and 1,2,3 and 2,1,3.

There is one subsequence with length 41,2,1,3.


Sample Input 2

Copy
1
1 1

Sample Output 2

Copy
1
1

There is one subsequence with length 11.

There is one subsequence with length 21,1.


Sample Input 3

Copy
32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9

Sample Output 3

Copy
32
525
5453
40919
237336
1107568
4272048
13884156
38567100
92561040
193536720
354817320
573166440
818809200
37158313
166803103
166803103
37158313
818809200
573166440
354817320
193536720
92561040
38567100
13884156
4272048
1107568
237336
40920
5456
528
33
1

Be sure to print the numbers modulo 109+7.

题目大意:从n+1个序列中选出长度为k的不同子序列的个数 
解题思路: 
注意到有两个相同的元素 
当子序列不含有相同的元素中间的元素时,子序列会被多算一次,其他情况确定,所以最终结果为: 
(C(n+1,k)-C(n-d,k-1))%MOD

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
const int N=;
const int maxn = 1e5 + ;
ll pos[maxn],fac[maxn],facm[maxn];
ll quick_pow(ll a,ll n,ll p)
{
ll x = a;
ll res = ;
while(n){
if(n & ){
res = ((ll)res * (ll)x) % p;
}
n >>= ;
x = ((ll)x*(ll)x) % p;
}
return res;
}
ll C(ll n,ll k){
if(k > n) return 0ll;
ll ans = fac[k]*fac[n-k]%MOD;
ans = (fac[n]*quick_pow(ans,MOD-2ll,MOD))%MOD;
return ans;
}
int main()
{
fac[] = ;
for(int i = ;i < maxn;i++)
fac[i] = (fac[i-]*i)%MOD;
ll n;
scanf("%lld", &n);
n++;
ll m, x;
for(int i = ;i <= n;i++){
scanf("%lld", &x);
if (pos[x]){
m = n - (i - pos[x] + );
break;
}
pos[x] = i;
}
for(int i = ;i <= n;i++)
printf("%lld\n", (C(n, i) - C(m, i-)+MOD) % MOD);
return ;
}

AtCoder Regular Contest 077 D - 11的更多相关文章

  1. AtCoder Regular Contest 077 被虐记&题解

    直到\(7:58\)才知道今天\(8:00\)有\(AtCoder\)的菜鸡来写题解啦. C - pushpush 题目: 给定一个长为\(n\)的序列,第\(i\)次操作做如下的事 : 将\(a_i ...

  2. AtCoder Regular Contest 077 E - guruguru

    https://arc077.contest.atcoder.jp/tasks/arc077_c 有m个点围成一个圈,按顺时针编号为1到m,一开始可以固定一个位置x,每次操作可以往顺时针方向走一步或直 ...

  3. AtCoder Regular Contest 077 C - pushpush

    题目链接:http://arc077.contest.atcoder.jp/tasks/arc077_a Time limit : 2sec / Memory limit : 256MB Score ...

  4. AtCoder Regular Contest 077

    跟身在国外的Marathon-fan一起打的比赛,虽然最后没出F但还是涨分了. C - pushpush 题意:n次操作,每次往一个序列后面塞数,然后把整个序列翻转. #include<cstd ...

  5. AtCoder Regular Contest 077 E - guruguru 线性函数 前缀和

    题目链接 题意 灯有\(m\)个亮度等级,\(1,2,...,m\),有两种按钮: 每次将亮度等级\(+1\),如\(1\rightarrow 2,2\rightarrow 3,...,m-1\rig ...

  6. 【arc077f】AtCoder Regular Contest 077 F - SS

    题意 给你一个形如"SS"的串S,以及一个函数\(f(x)\),\(x\)是一个形如"SS"的字符串,\(f(x)\)也是一个形如"SS"的 ...

  7. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  8. AtCoder Regular Contest 094 (ARC094) CDE题解

    原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...

  9. AtCoder Regular Contest 092

    AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...

随机推荐

  1. 前端 HTML body标签相关内容 常用标签 表单标签 form 表单控件分类

    表单控件分类 input标签: input标签 type属性的text,password,button按钮,submit按钮 input标签placeholder属性 标签上显示内容 input标签 ...

  2. laravel用crud修改产品items-新建resource controller和routing

    前面我们创建了laravel简单的items产品api,但是需要在数据库添加,如何在网页上直接添加呢?我们可以用view来操作crud(增加Create.读取查询Retrieve.更新Update和删 ...

  3. Vagrant测试

    载新的BOX实现虚拟机恢复.效果如下:(可用linux命令操作,但是很多时候我们还是需要图形化界面,不然不利于开发代码编写) 参考PDF中的记录网址http://www.vagrantbox.es/ ...

  4. Pycharm快捷键大全(windows + Mac)

    Windows快捷键 1.编辑 Ctrl + Space    基本的代码完成(类.方法.属性) Ctrl + Alt + Space  快速导入任意类 Ctrl + Shift + Enter    ...

  5. 从Trie树(字典树)谈到后缀树

    转:http://blog.csdn.net/v_july_v/article/details/6897097 引言 常关注本blog的读者朋友想必看过此篇文章:从B树.B+树.B*树谈到R 树,这次 ...

  6. kickstart模式实现批量安装centos7.x系统

    1.1 安装系统的方法 l  光盘(ISO文件,光盘的镜像文件)===>>每一台物理机都得给一个光驱,如果用外置光驱的话,是不是每台机器都需要插一下 l  U盘:ISO镜像刻录到U盘==& ...

  7. 关于PHP将对象数据写入日志的问题

    有时候在调试项目的时候,需要将一个对象或者对象的实例记录下来观察数据,如果用json_encode可能拿到的是空数据, 此时,改为使用 $data = print_r($data,1); 然后将 $d ...

  8. 【产品案例】我是如何从零搭建起一款健身O2O产品的?

    作者: Wander_Yang 我在年初参与到“SHAPE”这款健身产品的研发中,也算是第一次以产品经理的身份,从0开始负责一个产品的建立. 产品是一款O2O的智能健身连锁店,目前产品已经上线8个月, ...

  9. SQL Server2008 R2 数据库镜像实施手册(双机)SQL Server2014同样适用

    这篇文章主要介绍了SQL Server2008 R2 数据库镜像实施手册(双机)SQL Server2014同样适用,需要的朋友可以参考下 一.配置主备机 1. 服务器基本信息 主机名称为:HOST_ ...

  10. Graphviz

    不能显示中文,我的处理方法是: node [shape = box,fontname =“Microsoft YaHei”] edge [fontname =“Microsoft YaHei”] 似乎 ...