物理题+数学题+信息学题
1 #include<iostream>
2 #include<cmath>
3 using namespace std;
4 #define MAXN 101
5 #define PI 3.1415926
6 struct point
7 {
8 double x,y;
9 };
10 point a[MAXN];
11 double h,k;
12 double Max=0,Min=0,sum=0;
13 int n;
14 double angle(point A,point B)
15 {
16 double k1=atan2(A.y,A.x);
17 double k2=atan2(B.y,B.x);
18 if(k2-k1>PI) k1+=2*PI;
19 if(k1-k2>PI) k2+=2*PI;
20 return k2-k1;
21 }
22 int main()
23 {
24 int i;
25 scanf("%lf%lf%d",&k,&h,&n);
26 for(i=0;i<n;i++) scanf("%lf%lf",&a[i].x,&a[i].y);
27 a[n].x=a[0].x; a[n].y=a[0].y;
28 for(i=0;i<n;i++)
29 {
30 sum+=angle(a[i],a[i+1]);
31 if(sum<Min) Min=sum;
32 if(sum>Max) Max=sum;
33 if(Max-Min>=2*PI)
34 {
35 Max=Min+2*PI;
36 break;
37 }
38 }
39 printf("%.2f\n",(Max-Min)*k*h);
40 return 0;
41 }