10398  The Golden Pentagon
Moderator: Board moderators
10398  The Golden Pentagon
1. I did a binary search to find out r..is it ok?
2. If bin search is ok, to what precesion should i compute
I think this prob needs a special judge..
my r was:
1.3247179572447
3. Is there any other tricky points?
I also handled case with S= 0 specially..
Thanks
Light
2. If bin search is ok, to what precesion should i compute
I think this prob needs a special judge..
my r was:
1.3247179572447
3. Is there any other tricky points?
I also handled case with S= 0 specially..
Thanks
Light

 Guru
 Posts: 724
 Joined: Wed Dec 19, 2001 2:00 am
 Location: Germany

 Learning poster
 Posts: 63
 Joined: Thu Apr 04, 2002 2:00 am

 Learning poster
 Posts: 68
 Joined: Fri Oct 26, 2001 2:00 am
 Location: Dhaka, Bangladesh
 Contact:
10398(the golden pentagon)
i have solved this problem, but got WA....
i used the formula that, the one side of the first and 5th triangle is equal to the 6th trialngle....(i.e. if the one side of the first trianlge is 'S')then the equation becomes S + (S * (r^4)) = S* (r^5)....(here r is the geometrical progression ratio)
by solving we get....(r^4)*(r  1) = 1......i solved this with 6 places precision after the point. in bisection method by the following code:
[cpp]
long double equation(long double q)
{
return ((q*q*q*q)*(q1));
}
long double findr(long double lower, long double upper)
{
long double middle, ans;
for(;;)
{
middle = (upper + lower) /2;
ans = fabs(equation(middle)  1);
if(ans <= E) // E = 0.000001
return middle;
if(equation(middle) < 1.0)
lower = (upper + lower) / 2;
else
upper = (upper + lower) / 2;
}
}
[/cpp]
i initialize the upper and lower variable to 1.5 and 1.
then i use the folowing formula to find out a digit of say, a number N;
digit = ceill(log10(N));
when i printing the number(if digit < 10) i use floor to print the samller round integer number.
so can anyone help me to find out my error?
i used the formula that, the one side of the first and 5th triangle is equal to the 6th trialngle....(i.e. if the one side of the first trianlge is 'S')then the equation becomes S + (S * (r^4)) = S* (r^5)....(here r is the geometrical progression ratio)
by solving we get....(r^4)*(r  1) = 1......i solved this with 6 places precision after the point. in bisection method by the following code:
[cpp]
long double equation(long double q)
{
return ((q*q*q*q)*(q1));
}
long double findr(long double lower, long double upper)
{
long double middle, ans;
for(;;)
{
middle = (upper + lower) /2;
ans = fabs(equation(middle)  1);
if(ans <= E) // E = 0.000001
return middle;
if(equation(middle) < 1.0)
lower = (upper + lower) / 2;
else
upper = (upper + lower) / 2;
}
}
[/cpp]
i initialize the upper and lower variable to 1.5 and 1.
then i use the folowing formula to find out a digit of say, a number N;
digit = ceill(log10(N));
when i printing the number(if digit < 10) i use floor to print the samller round integer number.
so can anyone help me to find out my error?
Your WA is probably caused by the low precision you're using. My team member Adil got several WA just because he was keeping 14 places after the decimal point!! He finally got AC after keeping 15 places. You might try decreasing the error.
K M Hasan
http://www.cs.umanitoba.ca/~kmhasan/
http://www.cs.umanitoba.ca/~kmhasan/

 System administrator & Problemsetter
 Posts: 399
 Joined: Sat Jan 12, 2002 2:00 am
Hehe
Judge solution keeps upto 16 decimal places .
I get always WA and there's something I don't understand
HI!
I'm calculating K^(i1) where K=1,324717...
I've tried with 15 to 20 digits and it doesn't work :(
Also, I've realized that if the first side is 1, the second is 1,32... and the third is 1.7424, and it says "T indicates the length of a side of Ith triangle rounded to the nearest integer", so it should be 2, however if you read the sample output, is written 1. Where's the problem or the thing I'm not understanding?
I've tried booth rounding and flooring, but none works, I've tried also long double and making my own power function, but it doesn't work.
I think my program works, but I got WA always!!! Help please!!
Thanks
Alejandro
I'm calculating K^(i1) where K=1,324717...
I've tried with 15 to 20 digits and it doesn't work :(
Also, I've realized that if the first side is 1, the second is 1,32... and the third is 1.7424, and it says "T indicates the length of a side of Ith triangle rounded to the nearest integer", so it should be 2, however if you read the sample output, is written 1. Where's the problem or the thing I'm not understanding?
I've tried booth rounding and flooring, but none works, I've tried also long double and making my own power function, but it doesn't work.
I think my program works, but I got WA always!!! Help please!!
Thanks
Alejandro

 New poster
 Posts: 44
 Joined: Tue Apr 15, 2003 4:31 pm
 Location: Chittagong,Bangladesh
 Contact:
10398 why WA
In this problem i found r=1.32471795724474603;
i also handle specialy for 0 but still WA.
Can any one help me by some sample input output.
i also handle specialy for 0 but still WA.
Can any one help me by some sample input output.