Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
过了贴代码攒rp#include <string.h> #include <stdio.h> using namespace std; int duplicate(int * a,int n) { bool b[n]; memset(b,1,sizeof(b)); for(int i=0;i<n;i++) { if(b[a[i]]==false){return a[i];} b[a[i]]=false; } return 0; } int find(int * a,int n,int start,int target) { for(int i=start;i<n;i++) { if(a[i]==target){return i;} } return -1; } int main() { int c,n; while(scanf("%d %d\n",&c,&n)) { if(c==0&&n==0){return 0;} int a,sum=0; int * b=new int [n]; for(int i=0;i<n;i++) { scanf("%d",&a); sum+=a;sum%=c; b[i]=sum; } sum=duplicate(b,c); if(!sum) { int d=find(b,c,0,0); for(int i=0;i<=d;i++) { printf("%d ",i+1); } printf("\n"); } else { int i=find(b,c,0,sum); int j=find(b,c,i+1,sum); for(int k=i+1;k<=j;k++) { printf("%d ",k+1); } printf("\n"); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator