标签:nbsp pen set hid i+1 include blog exist chmod
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 3295 Accepted Submission(s):
1210
1 /* 2 前缀和取模 3 对于前缀和sum[1-i]%m==k 4 sum[i-j]%m==k 5 一定有sum[i+1-j]%m==0 6 */ 7 #include <cctype> 8 #include <cstdio> 9 #include <cstring> 10 11 const int MAXN=100010; 12 13 int T,n,m; 14 15 int sum[MAXN],cur[MAXN]; 16 17 inline void read(int&x) { 18 int f=1;register char c=getchar(); 19 for(x=0;!isdigit(c);c==‘-‘&&(f=-1),c=getchar()); 20 for(;isdigit(c);x=x*10+c-48,c=getchar()); 21 x=x*f; 22 } 23 24 int hh() { 25 read(T); 26 while(T--) { 27 read(n);read(m); 28 bool flag=false; 29 sum[0]=0; 30 memset(cur,0,sizeof cur); 31 for(int i=1;i<=n;++i) { 32 read(sum[i]); 33 sum[i]=(sum[i]+sum[i-1])%m; 34 ++cur[sum[i]]; 35 if(cur[sum[i]]>1||sum[i]==0) flag=true; 36 } 37 if(flag) printf("YES\n"); 38 else printf("NO\n"); 39 } 40 return 0; 41 } 42 43 int sb=hh(); 44 int main(int argc,char**argv) {;}
标签:nbsp pen set hid i+1 include blog exist chmod
原文地址:http://www.cnblogs.com/whistle13326/p/7517839.html