tjut 4869
来源:互联网 发布:c语言算法是什么 编辑:程序博客网 时间:2024/06/16 21:39
#include <iostream> #include <cstdio> #include <cstring> #include <ctime> #include <algorithm> #include <cmath> #include <queue> #include <vector> using namespace std; #define LL __int64 const int maxn=1e5+10; const int mod=1e9+9; LL c[maxn]; LL pow_mod(LL a,int b) { LL s=1; while(b) { if(b&1)s=s*a%mod; a=a*a%mod; b=b>>1; } return s; } int main() { int n,m; //freopen("C:\\Documents and Settings\\Administrator\\桌面\\in.txt","r",stdin); //freopen("C:\\Documents and Settings\\Administrator\\桌面\\out.txt","w",stdout); //printf("%I64d\n",pow_mod(2,10)); while(scanf("%d%d",&n,&m)!=EOF) { int i,j,k,x,p,q; i=j=0; for(k=0;k<n;k++) { scanf("%d",&x); //求最小1的个数i if(i>=x)p=i-x; else if(j>=x)p=((i&1)==(x&1)?0:1); else p=x-j; //求最大1的个数j if(j+x<=m)q=j+x; else if(i+x<=m)q=(((i+x)&1)==(m&1)?m:m-1); else q=2*m-(i+x); i=p;j=q; //printf("**%d %d\n",i,j); } LL ans=0; c[0]=1; if(i==0)ans+=c[0]; for(k=1;k<=j;k++) { if(m-k<k)c[k]=c[m-k]; else c[k]=c[k-1]*(m-k+1)%mod*pow_mod(k,mod-2)%mod; if(k>=i&&(k&1)==(i&1))ans+=c[k]; } printf("%I64d\n",ans%mod); } return 0; }
0 0
- tjut 4869
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- AngularJS Select(选择框)
- APPMES同步后编译错误
- Eclipes 菜鳥筆記一
- HDU(1009)FatMouse' Trade(贪心)
- Spring 教程
- tjut 4869
- Unreal4 shader 杂1
- 余弦距离、欧氏距离和杰卡德相似性度量的对比分析
- UVa 11090 Going in Cycle! BellmanFord 判负权环
- NHibernate-通过SQL-Query返回DataSet
- HDU5744(贪心)
- 28 个 MongoDB NoSQL 数据库的面试问答
- POJ 2531 Network Saboteur
- Django 的简单使用