Advertisement
Saleh127

CSES 1662

Apr 17th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll n,m=0,i,j=0,k;
  11.  
  12. cin>>n;
  13. map<ll,ll>x;
  14. x[0]=1;
  15. for(i=0;i<n;i++)
  16. {
  17. cin>>k;
  18. m+=k;
  19. m%=n;
  20. if(m<0) m+=n;
  21.  
  22. if(x[m]) j+=x[m];
  23.  
  24. x[m]++;
  25. }
  26. cout<<j<<endl;
  27.  
  28. return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement