Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("subsecv.in");
- ofstream g("subsecv.out");
- int v[10002];
- int main()
- { int n,x,st=999999,dr=999999,val,y;
- long long s=0;
- f>>n>>x;
- s=x;
- s%=n;
- v[s%n]=1;
- for(int i=2; i<=n; i++)
- {
- f>>x;
- s+=x;
- s%=n;
- if(s%n==0)
- {
- g<<1<<" "<<i;
- return 0;
- }
- if(!v[s%n])
- v[s%n]=i;
- else
- { if(v[s%n]<st)
- st=v[s%n],dr=i,val=s%n;
- else
- if(v[s%n]==st && i<dr)
- st=v[s%n],dr=i,val=s%n;
- }
- }
- g<<st+1<<" "<<dr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement