Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long zm;
  4. int n, m, wynik=1;
  5. int prefix[1000004], zlicz[1000004];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. prefix[0]=0;
  10. cin>>n>>m;
  11. for (int i=1; i<=n; i++)
  12. {
  13. cin>>zm;
  14. prefix[i]=prefix[i-1]+zm;
  15. prefix[i]=prefix[i]%m;
  16. }
  17. for (int i=1; i<=n; i++)
  18. zlicz[prefix[i]]++;
  19.  
  20. zlicz[0]++;
  21. wynik+=zlicz[0];
  22. zlicz[0]--;
  23.  
  24. for (int i=0; i<=n; i++)
  25. {
  26. zlicz[prefix[i]]--;
  27. wynik+=zlicz[prefix[i]];
  28. }
  29. cout<<wynik;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement