标签:des style blog http color os io strong
Time Limit: 1000MS | Memory Limit: 65536K | |||
Total Submissions: 6015 | Accepted: 2609 | Special Judge |
Description
Input
Output
Sample Input
5 1 2 3 4 1
Sample Output
2 2 3
Source
#include<cstdio> #include<cstring> const int maxn=10000+10; int a[maxn],mod[maxn],n; int main() { __int64 sum; while(~scanf("%d",&n)) { sum=0; for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=0;i<n;i++) mod[i]=-1; for(int i=1;i<=n;i++) { sum=(sum+a[i])%n; if(sum==0) { printf("%d\n",i); for(int j=1;j<=i;j++) printf("%d\n",a[j]); break; } if(mod[sum]!=-1) { printf("%d\n",i-mod[sum]); for(int j=mod[sum]+1;j<=i;j++) printf("%d\n",a[j]); break; } mod[sum]=i; } } return 0; }
poj2356Find a multiple(鸽笼原理),布布扣,bubuko.com
标签:des style blog http color os io strong
原文地址:http://blog.csdn.net/u014303647/article/details/38707593