Hi Guys,
The above picture shows my approach for this problem https://codeforces.net/contest/1354/problem/C1
Am basically using the interior angle subtended by 3 adjacent vertices and then to find the vertical ( perpendicular ) line's length using tan function
But am getting completely unexpected answer.
// -- MY CODE :
long double n;
cin >> n;
// long double angle = (((180 * (2*n — 2)) / (2*n) ) / 360) * 2 * 3.14
long double angle = ((((n — 1)) / n)) * 3.14;
cout << tan(angle) << endl;
PLEASE GUYS HELP ME FIND MY MISTAKE .
THANKS IN ADVANCE.
The angle(theta) is half of the interior angle, divide the theta by two and also take pi upto some more decimals to prevent WAs.
I meant in your code...it should be like this.
I have done it like u said but still getting unexpected ans
Code Snippet:
#define pi 3.14159265358979323846;
long double n;
cin >> n;
// long double angle = (((180 * (2*n — 2)) / (2*n)) / 360) * 2 * 3.14;
long double angle = (((n — 1)) / n) * pi;
cout << tan(angle) << endl;
You didn't see the change I did? I said to divide the angle(theta) by 2 in your code.
In your code:
It should be:
For maximum precision you can use:
Yeah right!
Hi Guys,
Thanks for the help , i finally solved it .
Am facing another new Problem in C2 (https://codeforces.net/contest/1354/problem/C2)
(This is the last one i promise)
-
In C2 problem this is my simple approach
and again am not able to identify why am getting unexpected output
(Is my approach incorrect?)
Code Snippet :
Please Help me out.
Thanks In Advance. :)
I don't think what you're doing is correct.
I may be wrong. But I did something different.
I think the ideal arrangement should be like this(my drawing's not too good)
Here's my code if you want to refer 80726717