DI am 100% sure that my task is correct. What is the problem?
http://www.z-trening.com/new/www/html/submit.php?submit=7100044111&subm_code=1
Thanks in advance.
oTry using pi = 3.1415926535897932
Nyou don't have to do that. pi is already defined in pascal so you don't need to define it as a constant
vCan you tell me what formulas to use for area?
I used : A = (n*r*r* Sin(360/pi ) )/2 , the result from sin function converted to degrees, but i get wrong result ,very wrong:D HELP...
Ni used A = n*r*r*sin(pi/n)*cos(pi/n) and it works
DThanks for the posts. I tried everything and again I got all wrong results. What is the problem?
Ni saw your code and the mistake is that you must use writeln for both area and perimeter. You can't use write. put writeln and test it.
N@diabolic
and 1 more thing. put longint instead of integer
DThank you very much for the tip. Now it works. But why longint, when it wasn't needed ? Is there any evaluator issue?
Ni thought longint was needed because n <= 100000 but integer range is [-32768..32767] so i have put longint immediately
N@vasja
A = N*R*R*SIN(2*PI/N)/2
We divide the polygon in N triangles each with an area equal to half of the area of a parallelograme (rhombus) with side R and angle 360/N (2*PI/N) between the sides. Therefore, the area of one triangle is P=R*R*SIN(2*PI/N)/2 and the total area equals N times the area P because all the triangles are congruent.
nIf you look better you will see that your A and P are the same except A is n times bigger than P.
You have a:=n*r*r*sin(2*pi/n)/2;
and that is your area, and that's good. But your perimeter is not good. Try to think how can you calculate perimeter. You have got R, and you have N, so if you split the N-polygon in N equal triangles, you will get a triangle with angle 2Pi/N and two side chains with length R, and the third one is the one you need to calculate perimeter. How to find the third one??? Use cosinus theorem and you can find the third side chain of triangle. Now that you have that length, just multiply it with N cuz you have N lengths and you get your perimeter.
sThis task is purely mathematical, runs O(1). :P
mI am not good at trigonometry
gyou don't need to be good at trigonometry to solve this problem..you need just basics of trigonometry
hMateo,
Parimeter = 2*n*r*sin(Pi/n)
Area = n*r*r*sin(Pi/n)*cos(Pi/n)
I'm hoping that I didn't make any mistake.
muse this
Parimeter = 2*n*r*sin(Pi/n)
Area = n*r*r*sin(Pi/n)*cos(Pi/n)