## 11189 - A Simple Pendulum

**Moderator:** Board moderators

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;

I used the following algorithm:
Is it right?I think it needn't swap the point.

Code: Select all

```
Cut off
```

Last edited by pineapple on Wed Mar 07, 2007 3:57 pm, edited 2 times in total.

Code: Select all

```
1 0 2 0 1 1 0 1
```

Code: Select all

```
Center(x, y) = (1.000, 0.500)
```

Code: Select all

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

Code: Select all

```
Cut off
```

Code: Select all

```
struct point
{
int x,y
}
```

Code: Select all

```
struct point
{
double x,y
}
```

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?