[CC-CMPVIRS] computer virus questions:
There is a tape, which is divided from left to right into \ (n \ le10 ^ 7) \) grids. At the beginning, the # \ (I \) number \ (I \) on the grid \). This tape is divided into consecutive \ (M \ le10 ^ 3) \) segments from left to right. The smaller segment is on the left of the larger segment, and each grid is allocated to a segment. The \ (I \) segment has \ (d_ I \) grids.
In addition, the number of cells with a large number cannot be smaller than the number of smaller segments, that is, \ (d_ I \ le D _ {I + 1 }\).
At the beginning, all the grids were white. Now, repeat the following operations until all the grids are dyed black:
- Dye the last lattice of each segment into black.
- Change the number written on each white lattice to the sum of the number written on it and the white lattice on its left. In this process, all the white grids are completed at the same time.
Calculate the number and, modulo \ (10 ^ 9 + 7 \) on the grid after all the grids are dyed black \).
Ideas:
Make some reasonable guesses to draw a conclusion (see the code ).
For proof, see the official question.
Source code:
#include<cstdio>#include<cctype>inline int getint() { register char ch; while(!isdigit(ch=getchar())); register int x=ch^'0'; while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0'); return x;}typedef long long int64;const int M=1001,mod=1e9+7;inline int power(int a,int k) { int ret=1; for(;k;k>>=1) { if(k&1) ret=(int64)ret*a%mod; a=(int64)a*a%mod; } return ret;}int d[M];int main() { const int n=getint(),m=getint(); int ans=mod-m; for(register int i=1;i<=m;i++) { int tmp=1; d[i]=getint(); for(register int j=0;j<i;j++) { tmp=(int64)tmp*power(i-j+1,d[j+1]-d[j])%mod; } (ans+=tmp)%=mod; } printf("%d\n",ans); return 0;}
[CC-CMPVIRS] Computer Virus