fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,t,i,j,z;
  6. cin>>t;
  7. while(t--)
  8. {
  9. cin>>n;int a[n],m=0;
  10. for(i=0;i<n;i++)
  11. {
  12. cin>>a[i];
  13. }
  14. for(i=0;i<n;i++)
  15. {
  16. int x=0;
  17. long long int f=1,k;
  18. for(j=i;j<(n);j++)
  19. {z=0;
  20. f=f*(abs(a[j]));float c=sqrt(f);
  21. c=ceil(c);
  22. for(k=0;k<=c;k++)
  23. {if((f)==((c-k)*(c+k)))
  24. {z=1;x++;;break;
  25.  
  26. }
  27.  
  28. }
  29.  
  30.  
  31. }
  32. if(x>=1)
  33. {
  34. m++;
  35. }
  36.  
  37. }
  38. cout<<m<<endl;
  39. }
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0s 4520KB
stdin
2
3
1 2 3
3
2 5 6
stdout
2
2