fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int test,i;
  6. vector<int>result;
  7. cin>>test;
  8. while(test--){
  9. int c,k,a,b,count1=0,total,real;
  10. cin>>c;
  11. k = c - 1;
  12. while(k>0){
  13. a = sqrt(pow(c,2) - pow(k,2));
  14. cout<<"a :"<<a<<" k: "<<k<<endl;
  15. cout<<"total "<<(pow(a,2)+pow(k,2));
  16. total = (pow(a,2)+pow(k,2));
  17. real = pow(c,2);
  18. // cout<<pow(c,2)<<endl;
  19. if(total != real)
  20. count1++;
  21. cout<<"\tcount :"<<count1<<endl;
  22. k--;
  23. }
  24. result.push_back(count1);
  25. }
  26. for(i=0;i<result.size();i++)
  27. cout<<"Case "<<i+1<<": "<<result[i]<<endl;
  28. }
  29.  
Success #stdin #stdout 0s 15240KB
stdin
2
5
10
stdout
a :3 k: 4
total 25	count :0
a :4 k: 3
total 25	count :0
a :4 k: 2
total 20	count :1
a :4 k: 1
total 17	count :2
a :4 k: 9
total 97	count :1
a :6 k: 8
total 100	count :1
a :7 k: 7
total 98	count :2
a :8 k: 6
total 100	count :2
a :8 k: 5
total 89	count :3
a :9 k: 4
total 97	count :4
a :9 k: 3
total 90	count :5
a :9 k: 2
total 85	count :6
a :9 k: 1
total 82	count :7
Case 1: 2
Case 2: 7