fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. using namespace __gnu_pbds;
  6. typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedset;
  7. #define MO2 ios_base::sync_with_stdio(false);cin.tie(NULL);
  8. #define endl '\n'
  9. #define int long long
  10. #define elif else if
  11. #define sz(x) long(x.size())
  12. #define all(vec) vec.begin(), vec.end()
  13. const int mod = 1e9 + 7;
  14. const int dx[] = {0, -1, 0, 1, 1, -1, 1, -1};
  15. const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1};
  16.  
  17. int n, m;
  18. void dope() {}
  19.  
  20. void solve() {
  21. int ans = 0;
  22. cin >> n;
  23. vector<int> vec(n);
  24. vector<bool> mp(n + 1);
  25. for (int i = 0; i < n;i++)
  26. cin >> vec[i];
  27. for (int i = 0; i < n; i++){
  28. int sum = 0;
  29. for (int j = i; j < n; j++) {
  30. sum += vec[j];
  31. if (sum>n) break;
  32. if (j >= i + 1)
  33. mp[sum] = true;
  34. }
  35. }
  36. for (auto&it:vec)
  37. if (mp[it])
  38. ans++;
  39. cout << ans;
  40. }
  41.  
  42. signed main() {
  43. MO2
  44. #if ONLINE_JUDGE || CPH
  45. #else
  46. freopen("Input.txt", "r", stdin);
  47. freopen("Output.txt", "w", stdout);
  48. #endif
  49. int nop = 1; cin >> nop;
  50. while (nop--)
  51. {
  52. solve();
  53. if (nop)
  54. cout << endl;
  55. }
  56. return 0;
  57. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty