## 11565 - Simple Equations

All about problems in Volume 115. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### 11565 - Simple Equations

Some one please help me I got so many WA in the contest and getting WA till now.
Here is my code.

Code: Select all

removed
Last edited by Obaida on Sun Dec 28, 2008 10:37 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Igor9669
Learning poster
Posts: 85
Joined: Sun Jun 08, 2008 12:58 pm

### Re: 11565 Simple Equations WA!!!

Read the statement more carefully ....
And you will find your bug!!!

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11565 Simple Equations WA!!!

Are you aiming for that???
If there are many possible answers, choose the one with the least value of x. If there is a tie, output the one with the least value of y.
But i can't find any difference between it and my solution.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Igor9669
Learning poster
Posts: 85
Joined: Sun Jun 08, 2008 12:58 pm

### Re: 11565 Simple Equations WA!!!

No, try this test:
3 1 3
Right answer is: No solution!

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11565 Simple Equations WA!!!

But now check this. It's also WA.

Code: Select all

removed
Last edited by Obaida on Sun Feb 15, 2009 3:32 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Igor9669
Learning poster
Posts: 85
Joined: Sun Jun 08, 2008 12:58 pm

### Re: 11565 Simple Equations WA!!!

I think this test will help you:
1 120 245
Answer is: -10 -1 12

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11565 Simple Equations WA!!!

Thank you very much i got the idea now.
try_try_try_try_&&&_try@try.com
This may be the address of success.

kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

### Re: 11565 Simple Equations WA!!!

thanx..Articuno
Last edited by kbr_iut on Tue Dec 30, 2008 9:19 pm, edited 3 times in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

Articuno
Learning poster
Posts: 78
Joined: Sun Nov 30, 2008 5:00 pm
Location: IUT-OIC, Dhaka, Bangladesh

### Re: 11565 Simple Equations WA!!!

The reason is described in the first line of the problem descryption.
We have three different integers, x, y and z,
May be tomorrow is a better day............

kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

### Re: 11565 - Simple Equations

sorry about my wrong input.
Last edited by kbr_iut on Tue Jan 13, 2009 9:29 pm, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

Igor9669
Learning poster
Posts: 85
Joined: Sun Jun 08, 2008 12:58 pm

### Re: 11565 - Simple Equations

input is not right!
Last edited by Igor9669 on Wed Dec 31, 2008 4:19 pm, edited 1 time in total.

kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

### Re: 11565 - Simple Equations

edited
Last edited by kbr_iut on Tue Jan 13, 2009 9:09 pm, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

Articuno
Learning poster
Posts: 78
Joined: Sun Nov 30, 2008 5:00 pm
Location: IUT-OIC, Dhaka, Bangladesh

### Re: 11565 - Simple Equations

I dont understand what you want to say, If you are asking about inputs>10000 and <1 then this should not be a concern. The problem descryption defines that all inputs will be within that range.
May be tomorrow is a better day............

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

### Re: 11565 - Simple Equations

Artincuno is right. The input numbers are all in the specified range. In fact the largest number in the input file is a bit less than 10000.
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

### Re: 11565 - Simple Equations

I am sorry for my previous wrong input.
anyway I got AC in O(n^2) solution.
but I am getting WA in O(n) solution...pliz anyone help.
code:

Code: Select all

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int valy,valz,valx,x,y,z,a,b,c,u,v,m,n,t;
bool flag;
#define inf 32767
int cal(){
int beg,end;
beg=-b;
while(beg<=b){
int i=beg;
v=2*i*i*i-2*a*i*i+a*a*i-c*i-2*b;
if(!v&&i)return i;
beg++;
}
return inf;
}
void fun(){
m=-m;
valy=(m+a-valx)/2;
if(valy==inf||valy==0||valy==valx)return;
valz=b/(valx*valy);
if(valz==inf||valz==0||valz==valx||valz==valy)return;
if(valx*valx+valy*valy+valz*valz!=c||valx*valy*valz!=b||valx+valy+valz!=a)return;
int y=max(valx,valy);
int x=valx+valy-y;
int z=a-x-y;
if(z>y)valx=x,valy=y,valz=z;
else if(z>x)valx=x,valy=z,valz=y;
else valx=z,valy=x,valz=y;
flag=true;
}
int main(){
int i,j,k,l;
#ifndef OINLINE_JUDGE
freopen("1.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
scanf("%d",&t);
while(t--){
scanf("%d%d%d",&a,&b,&c);
valx=cal();
if(valx==inf){printf("No solution.\n");continue;}
m=c-valx*valx-2*(b/valx);
m=sqrt(double(m))+.5;
flag=false;
fun();
if(!flag)fun();
if(flag)printf("%d %d %d\n",valx,valy,valz);
else printf("No solution.\n");
}
return 0;
}

Is there any wrong finding the value of x , y? Is my equation right?

sample input:

Code: Select all

29
3 1 3
3 3 3
1 8 21
17 108 121

10 0 100

47 240 1637

18 0 162

23 385 195

37 1664 489

17 0 145

44 544 1224

42 0 1394

24 0 386

12 24 74

8 0 40

55 629 1659

60 1410 2318

34 836 498

46 980 1290

19 56 213

11 48 41

57 3468 1481

52 2210 1350

8 0 130
0 30 38
0 30 38
1 4 9
5 0 13
3 0 5

sample output:

Code: Select all

No solution.
No solution.
-2 -1 4
2 6 9
No solution.
1 6 40
No solution.
5 7 11
8 13 16
No solution.
2 8 34
No solution.
No solution.
1 3 8
No solution.
1 17 37
3 10 47
4 11 19
4 7 35
1 4 14
No solution.
6 17 34
5 13 34
No solution.
-3 -2 5
-3 -2 5
No solution.
No solution.
No solution.

It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................