|
|
back to boardO(n) ,but it's WA!!!!!!!!!!!!!!!!!SOS!!! Posted by Seany 7 Aug 2003 19:50 #include<iostream> #include<fstream> using namespace std; int temp[10000]; int dic[10000]; int n; int Initial() { cin>>n; int id(-1); for(int i=0;i<n;i++) { cin>>dic[i]; temp[i]=dic[i]; if(i) dic[i]+=dic[i-1]; dic[i]%=n; if(dic[i]==0) { id=i; return id; } } return id; } void Proc() { int k=Initial(); if(k!=-1) { cout<<k+1<<endl; for(int i=0;i<=k;i++) cout<<temp[i]<<endl; return; } for(int i=0;i<n;i++) { int start(-1); for(int j=0;j<i;j++) if(dic[j]==dic[i]) { start=j; break; } if(start==-1) continue; cout<<i-start<<endl; for(int k=start+1;k<=i;k++) cout<<temp[k]<<endl; return; } cout<<0<<endl; } int main(int argc, char* argv[]) { Proc(); return 0; } |
|
|