## 11571 - Simple Equations - Extreme!!

Moderator: Board moderators

New poster
Posts: 1
Joined: Sat Sep 17, 2016 7:29 am

### Re: 11571 - Simple Equations - Extreme!!

here's my code

Code: Select all

``````#include<bits/stdc++.h>
using namespace std;
typedef long double ll;
int main(){
//freopen("FighterAttack.txt", "r", stdin);
//freopen("FighterShow.txt", "w", stdout);
ll A,B,C,n;
cin>>n;
while(n--)
{
ll minx=6000000000000,miny=600000000000,minz=0;
bool flag=false;
cin>>A>>B>>C;
for(ll x=0; x<=100000 ; x++)if(x*x<=C && ceil(B/x)==floor(B/x)){
for(ll y=0; y<=1000000; y++)if(x!=y && x*x+y*y<=C && ceil(B/y)==floor(B/y)){
ll z = A-(x+y);
if(x+y+z==A && x*y*z==B && x*x+y*y+z*z==C && x!=y && x!=z && y!=z){
if(x<minx){minx=x; miny=y; minz=z; flag=true;}
else if(x==minx){ if(y<miny){minx=x; miny=y; minz=z;} }
}
}
}
if(flag)
cout<<minx<<" "<<miny<<" "<<minz<<endl;
else
cout<<"No solution.\n";
}
return 0;
}``````
Why i get TimeLimit Error?

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: 11571 - Simple Equations - Extreme!!

I fixed bug in my code, so it passes all 249 cases in brianfry713's input. Accepted in 0.0 s.