10432 - Polygon Inside A Circle

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

p!ter
New poster
Posts: 11
Joined: Thu Nov 18, 2004 8:55 pm

Post by p!ter »

Hi sohel
I rebuild my code and got ACC... :D :D :D
Thanx!!!!!!!!
It is not mantioned that radius can be real :evil:

J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Location: Daffodil University,Dhaka,Bangladesh
Contact:

Post by J&Jewel »

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;
}
I hate Wrong Answer!

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

10432 - WA grrr

Post by challenger »

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
Location: Calgary, Canada

Post by Darko »

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

Post by challenger »

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
Location: Calgary, Canada

Post by Darko »

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...

Post by gvs »

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:

Post by Ankur Jaiswal »

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
Location: Dhaka,Bangladesh
Contact:

10432 output limit xceed!!!

Post by kolpobilashi »

[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;
}

:cry: [/code]
Sanjana

Moha
Experienced poster
Posts: 216
Joined: Tue Aug 31, 2004 1:02 am
Location: Tehran
Contact:

Post by Moha »

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
Location: Dhaka,Bangladesh
Contact:

Post by kolpobilashi »

thanx a lottt!!! :D
Acc now :)
Sanjana

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

10432, WA, help me!

Post by deena sultana »

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
Location: Bangladesh
Contact:

Post by emotional blind »

Unfortunately your formula is Wrong
If u use sin instead of asine it should be right


If you get ACCEPTED
Dont be lazy to remove your code please
otherwise it spoils the problem

Best wishes

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Unfortunately your formula is Wrong
If u use sin instead of asine it should be right


If you get ACCEPTED
Dont be lazy to remove your code please
otherwise it spoils the problem

Best wishes

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

Post by deena sultana »

emotional blind

u r sooooooooo nice.
Thank u very much.
i get ac now. :D

Post Reply

Return to “Volume 104 (10400-10499)”