## 10432 - Polygon Inside A Circle

Moderator: Board moderators

p!ter
New poster
Posts: 11
Joined: Thu Nov 18, 2004 8:55 pm
Hi sohel
I rebuild my code and got ACC...
Thanx!!!!!!!!
It is not mantioned that radius can be real

J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Contact:
My program is ok for sample input output
can anybody give me some I/O...plz..
or any hints..

Code: Select all

``````#define PI acos(0)
int main()
{
double r,angle,area;
int n;
//freopen("F:\\10432.txt","r",stdin);
while(scanf("%lf%d",&r,&n)==2)
{
angle=180-((double)180*(n-2)/n);
area=sin(PI/180*angle)*r*r*n/2.0;
printf("%.3lf\n",2*area);
}
return 0;
}``````

challenger
New poster
Posts: 6
Joined: Sun Jan 23, 2005 8:21 pm

### 10432 - WA grrr

I am always getting Wrong Answer (WA) ! Why is that?
Can anyone find the bug in my code? I would really appreciate that.

Code: Select all

``````#include <stdio.h>
#include <math.h>

#define pi 2.*acos(0)

main()
{
float r,n,b,h,ang,area;

while( scanf("%f %f",&r,&n)==2 )
{
ang=(2.*pi)/n;
b=r*sin(ang);
h=sqrt(r*r-b*b/4.);
area=n*(b*h/2.);
printf("%.3f\n",area);
}
}
``````

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
I think you should use doubles. And there is a simple formula for the area.

I don't even think your formula should work - b should be 2.0*r*sin(ang/2.0), draw a picture.

Try

1 4
0.7071 4

you should get
2.000
1.000

Darko

challenger
New poster
Posts: 6
Joined: Sun Jan 23, 2005 8:21 pm
Ok! I fixed the double thing and the base and height formulads

[removed]

Double in ANSII is %f but I had to change it to %lf ... that was my error.
Last edited by challenger on Sun Mar 05, 2006 6:39 pm, edited 1 time in total.

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Heh, I'm glad for you, but you shouldn't be posting accepted code, please remove it.

Darko

gvs
New poster
Posts: 6
Joined: Sun Jun 19, 2005 7:39 pm

### grrr...

does anybody know why this occurs ?
I tried my code on both Windows, and Ubuntu, but there was no difference... I used acos(0.0) for pi... and kept getting WA.
But when i used acos(-1.0), i finally got AC...

god knows why ....
this is the 3rd such problem I've faced in the last 5... n it's drivin me crazy...

makes coding much more difficult and infuriating...
maKe wHat yoU waNt...... you'll succeed

Ankur Jaiswal
New poster
Posts: 31
Joined: Sat Apr 01, 2006 6:24 am
Contact:
may be the WA's came bcoz u took the value of PI from any other source(may be u have searched google or seen math.h).
In general always use PI=2*acos(0.0). you wont get precision errors then.

kolpobilashi
Learning poster
Posts: 54
Joined: Mon Jan 02, 2006 3:06 am
Contact:

### 10432 output limit xceed!!!

[code]

#include<stdio.h>
#include<math.h>

int main()
{
int r,n;
while(scanf("%d %d",&r,&n)!=EOF)
{
double s,f,PI;
PI=2*acos(0.0);
f=sin(2*PI/(double)n);
s=(double)(.5*r*r*f*n);
printf("%.3lf\n",s);
}
return 0;
}

[/code]
Sanjana

Moha
Experienced poster
Posts: 216
Joined: Tue Aug 31, 2004 1:02 am
Location: Tehran
Contact:
the problem statements dosn't say that 'r' is an integer number . read it as a double and try again.

kolpobilashi
Learning poster
Posts: 54
Joined: Mon Jan 02, 2006 3:06 am
Contact:
thanx a lottt!!!
Acc now
Sanjana

deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm
Contact:

### 10432, WA, help me!

Hi, friends, again i need your help.
i got WA for 10432. but i dont understand why.
would you plz help me?

Code: Select all

``````Removed After AC;
``````
Last edited by deena sultana on Sun Jun 25, 2006 7:33 pm, edited 1 time in total.

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:
If u use sin instead of asine it should be right

If you get ACCEPTED
otherwise it spoils the problem

Best wishes

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:
If u use sin instead of asine it should be right

If you get ACCEPTED
otherwise it spoils the problem

Best wishes

deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm