1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#include <iostream> #include <cmath> #include <cstdio> #include <vector> #include <algorithm> using namespace std; vector<int> vb; int main() { int t; int A,B,C; cin>>t; while(t--) { cin>>A>>B>>C; bool found=0; vb.clear(); for(int i=-100;i<=100;i++) { for(int j=-100;j<=100;j++) { for(int k=-100;k<=100;k++) { if(i+j+k==A) if(i*j*k==B) if(i*i+j*j+k*k==C) if(i!=j && i!=k && j!=k) { vb.push_back(i);vb.push_back(j);vb.push_back(k); found=1; i=101;j=101;k=101; } } } } if(found) { sort(vb.begin(),vb.end()); cout<<vb[0]<<" "<<vb[1]<<" "<<vb[2]<<"\n"; } else cout<<"No solution.\n"; } return 0; } |