11189 - A Simple Pendulum

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

Moderator: Board moderators

Post Reply
User avatar
cytmike
Learning poster
Posts: 95
Joined: Mon Apr 26, 2004 1:23 pm
Location: Hong Kong and United States
Contact:

11189 - A Simple Pendulum

Post by cytmike » Sun Mar 04, 2007 8:08 pm

Can anybody offer some hint?
Impossible is Nothing.

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sun Mar 04, 2007 8:15 pm

Compute coordinates of G (center of masses), and distance from it to point A from formulas in the problem statement.
Find points of intersection of circle of radius AG and center in G with the polygon.

pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post by pineapple » Wed Mar 07, 2007 11:11 am

I always get WA.Could anyone who have got AC post some critical cases for me.I used the following algorithm to count d:
for each line segment p1p2, first calculate d1=|Cp1|,d2=|Cp2|.C is the center of the quadrilateral.
1) if((AG>d1&&AG<d2)||(AG<d1&&AG>d2)) then d=d+1
2) else if(AG<d1&&AG<d2)
check whether there are two intersecting point:
assume CI plumb p1p2 calculate the coordinate of I.
if(I is a point of p1p2&&CI<AG) then d=d+2
else d=d+0
3) else d=d+0;

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Wed Mar 07, 2007 11:23 am

How did you calculate the center of the quadrilateral ?

pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post by pineapple » Wed Mar 07, 2007 12:41 pm

I used the following algorithm:

Code: Select all

Cut off
Is it right?I think it needn't swap the point.
Last edited by pineapple on Wed Mar 07, 2007 3:57 pm, edited 2 times in total.

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Wed Mar 07, 2007 3:33 pm

Here is a case that your code doesn't work. Consider this quadrilateral.

Code: Select all

1 0 2 0 1 1 0 1
The Center of this quadrilateral must be

Code: Select all

Center(x, y) = (1.000, 0.500)
but your code outputs

Code: Select all

Center(x, y) = (0.777, 0.444)

pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post by pineapple » Wed Mar 07, 2007 4:02 pm

Yes,I made a silly mistake in my previous code,but actual I have corrected it about 2 hours ago.This must be right.But I also get WA.

Code: Select all

Cut off

pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post by pineapple » Wed Mar 07, 2007 4:19 pm

Very strange.When I only change

Code: Select all

struct point
{
int x,y
}
to

Code: Select all

struct point
{
double x,y
}
and get AC.
other variables' type I used are all double expect i and d.
So I think it should be still feasible.Actually,Other parts are all OK.But WA!However,Thanks for your great help.
By the way,could you tell me why your code is so efficient that runs only 0.006S,actually I know some of problems you have solved are also very nice,the rank is quite high.Could you share it with me?

Post Reply

Return to “Volume 111 (11100-11199)”