11042  Complex, difficult and complicated
Moderator: Board moderators

 Experienced poster
 Posts: 105
 Joined: Wed May 25, 2005 7:23 am
11042  Complex, difficult and complicated
hi,
Does anyone have testcases for the problem 11042. When i submit the code, the problem says received but nothing about status.
Can someone post good test cases.
Does anyone have testcases for the problem 11042. When i submit the code, the problem says received but nothing about status.
Can someone post good test cases.

 Experienced poster
 Posts: 105
 Joined: Wed May 25, 2005 7:23 am
HI,
I am getting WA. Can some one tell me where i am doiing things wrong .
I am getting WA. Can some one tell me where i am doiing things wrong .
Code: Select all
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
# define M_PI 3.14159265358979323846 /* pi */
double sqrt(double );
double atan(double );
double fabs(double );
int main()
{
int i,a,b,no,k;
double m,n,z;
scanf(" %d",&no);
while(no)
{
scanf(" %d %d",&a,&b);
z=sqrt(a*a + b*b);
if(a==0)
m=M_PI/2;
else
m=atan((double)b/(double)a);
if(m==0)
{
printf("1\n");
continue;
}
k=fabs(M_PI/m);
if (fabs(fabs(k*m )  M_PI) < 0.00009)
{
if(pow(z,k) <= pow(2,30))
printf("%d\n",k);
else
printf("TOO COMPLICATED\n");
}
else
printf("TOO COMPLICATED\n");
}
return 0;
}
Here are some inputs for which your program gave wrong answer (at least, on my computer):
Correct answer for the first case is 1, for the rest  "TOO COMPLICATED".
Code: Select all
5
0 0
153 265
153 265
97 168
97 168
This is the top Google link:
http://www.clarku.edu/~djoyce/complex/
The program above uses "polar coordinates", I solved it using cartesian coordinates ("complex plane"). (check the corresponding parts in that tutorial)
http://www.clarku.edu/~djoyce/complex/
The program above uses "polar coordinates", I solved it using cartesian coordinates ("complex plane"). (check the corresponding parts in that tutorial)
 arsalan_mousavian
 Experienced poster
 Posts: 111
 Joined: Mon Jan 09, 2006 6:19 pm
 Location: Tehran, Iran
 Contact:
Not exactly , you nead a condition to stop the loop ( for the case that the result is TOO COMPLICATED ) but the rest is completely brute forceshamim wrote:Is the solution simply to loop over N and stop when the number becomes real. If so, when should the looping stop if there is no solution.Jan wrote:I used brute force and got Accepted in 0.000 seconds.
hope it helps
Darko wrote:I picked n=1000 and it worked. One could probably come up with a case that breaks it. (hm, maybe not  a,b are integers and they'll end up being > 2^30 really fast... silly me.. why did I pick such a high number?)
I choose 100 and got AC.
Is it always true, as n increases the abs(real) part will also increase. Since i*i is 1, shouldn't at times, the real part decrease or something.
Spoiler
My method is 
My method is 
Code: Select all
Suppose a and b given...
I considered x=1 and y=0
1. I have two complex numbers 
P = x + iy
Q = a + ib
2. Every time multiply P and Q and update x, y (x, y to srore the multiplication results. x contains real part and y contains complex part) .
3. If abs (x) > 2^30 then TOO COMPLICATED. End.
4. If y = 0, Got the Solution. End.
5. Goto step 1.
Ami ekhono shopno dekhi...
HomePage
HomePage
Hi guys,
Spoiler
I think there can not be any input which output is greater than 4.
There is only 4 Possible output for the problem
1. 1
2. 2
3. 4
4. TOO COMPLICATED
Try to categorize all the input into 4 partition and you can solve it using only few Ifelse.
No need to use any loop
No need to use any cos or sin function
Sorry for my poor english
Take care
Spoiler
I think there can not be any input which output is greater than 4.
There is only 4 Possible output for the problem
1. 1
2. 2
3. 4
4. TOO COMPLICATED
Try to categorize all the input into 4 partition and you can solve it using only few Ifelse.
No need to use any loop
No need to use any cos or sin function
Sorry for my poor english
Take care
Practice Makes a man perfect
 Martin Macko
 A great helper
 Posts: 481
 Joined: Sun Jun 19, 2005 1:18 am
 Location: European Union (Slovak Republic)
I don't think so... for the input:I think there can not be any input which output is greater than 4.
There is only 4 Possible output for the problem
1. 1
2. 2
3. 4
4. TOO COMPLICATED
1
96 32
the output is
12
Visit my script to hunt UVA problem here:
http://felixhalim.net/uva/hunting/

Felix Halim
http://felixhalim.net/uva/hunting/

Felix Halim