fork download
  1. #include<bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. int n;
  5. map<int,int>p;
  6. int dem=0;
  7. signed main()
  8. {
  9. cin>>n;
  10. int a[n+1],b[n+1],ans=0;
  11. p[0]=1;
  12. for (int i=1;i<=n;i++)
  13. {
  14. cin>>a[i];
  15. b[i]=(a[i]%n+n)%n;
  16. }
  17. for (int i=1;i<=n;i++)
  18. {
  19. ans+=b[i];
  20. dem=dem+p[ans%n];
  21. p[ans%n]++;
  22. }
  23. cout<<dem;
  24. }
  25.  
Success #stdin #stdout 0s 5292KB
stdin
5
3 1 2 7 4
stdout
1