Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f("subsecv.in");
  5. ofstream g("subsecv.out");
  6. int v[10002];
  7. int main()
  8. { int n,x,st=999999,dr=999999,val,y;
  9. long long s=0;
  10. f>>n>>x;
  11. s=x;
  12. s%=n;
  13. v[s%n]=1;
  14. for(int i=2; i<=n; i++)
  15. {
  16. f>>x;
  17. s+=x;
  18. s%=n;
  19. if(s%n==0)
  20. {
  21. g<<1<<" "<<i;
  22. return 0;
  23. }
  24. if(!v[s%n])
  25. v[s%n]=i;
  26. else
  27. { if(v[s%n]<st)
  28. st=v[s%n],dr=i,val=s%n;
  29. else
  30. if(v[s%n]==st && i<dr)
  31. st=v[s%n],dr=i,val=s%n;
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. }
  39. }
  40. g<<st+1<<" "<<dr;
  41.  
  42.  
  43.  
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement