Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- long x,s,sc;
- int M, N,*v=new int[100001],i,j,max;
- while (cin >> N >> M){
- s = 0;
- max = 0;
- for (i = 1; i <= N; i++){
- cin >> x;
- v[i] = x%M;
- s += v[i];
- }
- for (i = 1; i <= N; i++){
- sc = s;
- for (j = N; j >= i+max; j--)
- {
- if (sc%M == 0)
- if (j - i +1> max)
- max = j - i + 1;
- else
- break;
- sc -= v[j];
- }
- s -= v[i];
- }
- cout << max<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement