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

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan » Wed Aug 13, 2003 5:48 pm

Thanx for tip, boss!
Muchas gracias!!

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan » Sun Aug 17, 2003 7:44 am

I have an another question.
Suppose the number of sides is 2000, then the circle will be divided in 2000 parts which will make the angle of every part 360/2000 degree.
So to calculate the sin is:

Code: Select all

pi=3.141593;
angle=sin(2*pi/n);
Am I correct?

Faizur
New poster
Posts: 39
Joined: Fri Jun 06, 2003 3:04 pm

Post by Faizur » Tue Aug 19, 2003 6:25 am

I think you should better use pi=2*acos(0)

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan » Wed Aug 20, 2003 6:07 am

Thanx dude!!!
Finally got it AC in this darn prob!! :D :D :D :D

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan » Wed Aug 20, 2003 12:12 pm

Now I got another conversion prob.
Can anyone tell me how to convert minutes to degrees? :-? :-?
Thanx in advance.

User avatar
UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post by UFP2161 » Wed Aug 20, 2003 2:16 pm

1 (arc) second = 1/60 (arc) minute = 1/60 degree
Last edited by UFP2161 on Wed Aug 20, 2003 4:21 pm, edited 2 times in total.

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer » Wed Aug 20, 2003 2:50 pm

should it be:
1 deg = 60 min = 3600 sec ?
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

Faizur
New poster
Posts: 39
Joined: Fri Jun 06, 2003 3:04 pm

Post by Faizur » Fri Aug 22, 2003 1:38 pm

I think so...

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan » Mon Aug 25, 2003 9:58 am

I've tried both
1 (arc) second = 1/60 (arc) minute = 1/60 degree
and
1 deg = 60 min = 3600 sec
and find the second is the correct one.
Thanx anyway for the help guys!!!
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

10432

Post by WR » Wed Feb 25, 2004 10:24 am

Hi,

I'm getting a WA for this problem.

First I tried a straightforward approach:
- divide the polygone into triangles,
- compute height and base of a triangle
- compute the area of a triangle
- multiply by no. of triangles to get the area of the polygone.

---> WA

After that I tried the equations I've found here.

---> WA

Subsequently I created a file containing 5000 random values in the
range 1 .. 20000 and ran all four versions.

Identical results but WA.

Code: Select all

int main(void)
{
  int r, n;
  double area, dn, dr;
  double al, h, x, x2, b;
  double PI;
  while (scanf("%lf %d",&dr,&n) == 2){
    dn = (double) n;
/*    dr = (double) r;*/
    printf("\n");

/* 1st version: WA
   compute height and base for a triangle,
   find area and multiply by n
    PI = 3.1415926535897932384626;
    al = 180.0/dn;
    x = 2.0*dr*sin(al*PI/180.0);
    x2 = x*0.5;
    h = sqrt(dr*dr-x2*x2);
    area = dn*(x*h*0.5);
    printf("%.3lf\n",area);*/

/* 2nd version: WA
   simplified equation from a post
    PI = 3.1415926535897932384626433832795029L;
    al = 180.0 - ((double)180.0*(dn-2.0)/dn);
    area = (sin(PI/180.0*al)*dr*dr*dn)/2.0;
    printf("%.3lf\n",area);  */

/* 3rd version: WA
   same as eq. 2 with some constants replaced 
    PI = 2.0*acos(0.0);
    b = acos(-1.0);
    al = b - (b*(dn-2.0)/dn);
    area = (sin(PI/b*al)*dr*dr*dn)*0.5;
    printf("%.3lf\n",area);    */

/* 4th version: WA
   same as 3 with new eq. for sin(alpha) */
    al = sin(acos(-1.0)*2.0/n);
    area = (al*dr*dr*dn)*0.5;
    printf("%.3lf\n",area);
  }
  return 0;
}
Hints and/or test data would be very welcome!

Thanks

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Wed Feb 25, 2004 11:08 am

I use 4th way and got Acc ...

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Wed Feb 25, 2004 11:54 am

Yes, me too, thanks a lot.

But I'm still asking myself why the first three solutions
resulted in a WA.

As I said, they produced absolutely identical results
(maybe it's a Windows -- Linux problem?). No idea!
But leaves one wondering how to solve other geometrical
problems.

Ok, thanks again.

Dani Rodrigo
New poster
Posts: 11
Joined: Sun Jul 18, 2004 1:39 am

Post by Dani Rodrigo » Fri Jan 21, 2005 2:38 am

I received WA many times. I don't know the reason, but finally I read numbers as doubles and got AC.

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

10432 - Polygon Inside A Circle Why WA?

Post by p!ter » Fri Jan 21, 2005 11:36 am

Hi,
Can someont tell me what is wrong with my code.
Outputs seems ok

Code: Select all

Code removed after accepted
Thanks in advance!!!!!!
Last edited by p!ter on Wed Jan 26, 2005 6:25 pm, edited 1 time in total.

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

radius...

Post by sohel » Tue Jan 25, 2005 8:01 am

Radius may not always be integers.. it might take real values.

and it is safer to use acos(-1) for PI rather than 3.1415.......

Post Reply

Return to “Volume 104 (10400-10499)”