fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4. ll a[2005];
  5. int main()
  6. {
  7. ll i,j,k,n,m,t;
  8. scanf("%I64d",&t);
  9. while(t--)
  10. {
  11. scanf("%I64d",&n);
  12. ll tot=0;
  13. for(i=0;i<n;i++)
  14. {
  15. scanf("%I64d",&a[i]);
  16. tot+=a[i];
  17. }
  18. ll ans=0;
  19. for(i=0;i<n;i++)
  20. {
  21. ll pre=1,sum=0;
  22. for(j=i;j<n;j++)
  23. {
  24. sum+=a[j];
  25. pre=(pre*a[j])/(__gcd(pre,a[j]));
  26. if(pre>tot)
  27. break;
  28. if(sum>=pre)
  29. {
  30. if(sum%pre==0)
  31. ans+=1;
  32. }
  33. }
  34. }
  35. printf("%I64d\n",ans);
  36. }
  37. }
  38.  
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
Standard output is empty