Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define fr(i, n, m) for(int i = (n); i < (m); i ++)
  3. #define pb push_back
  4. #define st first
  5. #define nd second
  6. #define pq priority_queue
  7. #define all(x) begin(x), end(x)
  8.  
  9. using namespace std;
  10. typedef long long ll;
  11. typedef long double ld;
  12. typedef pair<int,int> pii;
  13. ll const inf = 1e9;
  14. ll const mod = 1e9 + 7;
  15. ld const eps = 1e-13;
  16.  
  17. unordered_map<ll, int> mapa;
  18. int main()
  19. {
  20. int n;
  21. cin >> n;
  22. ll a[n];
  23.  
  24. mapa[0] = 1;
  25.  
  26. ll ans = 0;
  27. ll sum = 0;
  28. fr(i, 0, n){
  29. cin >> a[i];
  30. sum += a[i];
  31. ans += mapa[sum];
  32. mapa[sum]++;
  33. }
  34. cout << ans << endl;
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement