Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin ("subsecv.in");
- ofstream fout ("subsecv.out");
- short n;
- short R[10007]; /// R[j]=i -> a[i]%n=j;
- short st, dr;
- int main()
- {
- short i, rest = 0;
- int x;
- fin >> n;
- st = n + 1;
- dr = 0;
- for (i = 1; i <= n; i++)
- {
- fin >> x;
- rest = (rest + x) % n;
- if (rest == 0)
- {
- fout << "1 " << i << "\n";
- return 0;
- }
- if (R[rest] != 0) /// Acest rest s-a mai obtinut
- {
- if (st > R[rest] + 1)
- {
- st = R[rest] + 1;
- dr = i;
- }
- }
- else R[rest] = i;
- }
- fout << st << " " << dr << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement