Saleh127

CF 1352E

Jul 7th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. test
  10. {
  11. ll a[10000],c,d[10000]={0},e=0,f,i,j,k,l;
  12. cin>>c;
  13. for(i=0;i<c;i++)
  14. {
  15. cin>>a[i];
  16. d[a[i]]++;
  17. }
  18. for(i=0;i<c;i++)
  19. {
  20. f=0;
  21. for(j=i;j<c;j++)
  22. {
  23. f+=a[j];
  24. if(j==i) continue;
  25. if(f<=c)
  26. {
  27. e+=d[f];
  28. d[f]=0;
  29. }
  30. }
  31. }
  32. cout<<e<<endl;
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment