标签:直接 [1] har ++i c++ etc poi std desc
1 #include <bits/stdc++.h> 2 #define il inline 3 #define RG register 4 #define ll long long 5 #define rhl (1000000007) 6 #define S (1048576) 7 8 using namespace std; 9 10 int f[10][S],g[S],a[S],m,n,d; 11 12 il int gi(){ 13 RG int x=0,q=1; RG char ch=getchar(); 14 while ((ch<‘0‘ || ch>‘9‘) && ch!=‘-‘) ch=getchar(); 15 if (ch==‘-‘) q=-1,ch=getchar(); 16 while (ch>=‘0‘ && ch<=‘9‘) x=x*10+ch-48,ch=getchar(); 17 return q*x; 18 } 19 20 il int add(RG int a,RG int b){ 21 a+=b; if (a>=rhl) a-=rhl; return a; 22 } 23 24 int main(){ 25 #ifndef ONLINE_JUDGE 26 freopen("nim.in","r",stdin); 27 freopen("nim.out","w",stdout); 28 #endif 29 n=gi(),d=gi(),f[0][0]=1; 30 for (RG int i=1,x;i<=n;++i) ++a[x=gi()],m=max(m,x); 31 for (RG int i=1,bin=1;i<=m;++i){ 32 while (bin<=i) bin<<=1; 33 while (a[i]--){ 34 for (RG int k=0;k<bin;++k) g[k]=add(f[0][k^i],f[d-1][k]); 35 for (RG int j=d-1,x;j;--j) 36 for (RG int k=0;k<bin;++k){ 37 if (k>(k^i)) continue; 38 x=f[j][k],f[j][k]=add(f[j-1][k],f[j][k^i]); 39 f[j][k^i]=add(f[j-1][k^i],x); 40 } 41 for (RG int k=0;k<bin;++k) f[0][k]=g[k]; 42 } 43 } 44 cout<<add(f[0][0],rhl-(n%d==0)); return 0; 45 }
bzoj4347 [POI2016]Nim z utrudnieniem
标签:直接 [1] har ++i c++ etc poi std desc
原文地址:http://www.cnblogs.com/wfj2048/p/7668102.html