Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <stack>
- #include <queue>
- #include <list>
- #include <vector>
- #include <map>
- #include <set>
- #include <sstream>
- #include <stdlib.h>
- #include <cmath>
- #define LL unsigned long long
- using namespace std;
- int main() {
- int t,A,B,C;
- scanf("%d",&t);
- while(t--){
- scanf("%d %d %d",&A,&B,&C);
- bool sol=false; int x,y,z;
- for(x=-22;x<=22 && !sol ;x++) if(x*x<=C)
- for(y=-100 ; y<=100 && !sol; y++) if(y!=x && x*x + y*y<=C)
- for(z=-100;z<=100 && !sol;z++)
- if(z!=x && z!=y && x+y+z==A && x*y*z==B && x*x + y*y + z*z ==C){
- printf("%d %d %d\n",x,y,z);
- sol=true;
- }
- if (!sol) printf("No solution.\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement