WA估计是精度问题
#include<stdio.h>
#include<string.h>
#include<math.h>
struct Point
{
float x, y;
};
float t;
float aB;
float moveA;
Point center;
float y;
float distan(Point p1, Point p2)
{
float dis=(float)sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
return dis;
}
float area()
{
float A;
A=(float)(2.0*acos(-1.0)-2.0*(acos(y/432000.0)));
float Area1=A/2.0*432000.0*432000.0;
Area1+=(float)(y*(432000.0*sin(acos(y/432000.0))));
float result=(Area1/(acos(-1.0)*432000.0*432000.0));
if(result<1)
return result;
else
return 1.0;
}
void run()
{
float A=aB-moveA;
Point pc;
pc.x=(float)cos(A)*3950.0;
pc.y=-(float)sin(A)*3950.0;
float lineA=(float)(acos(-1.0)-(A-acos(-1.0)/2.0));
float k=tan(lineA);
if(tan(lineA)>acos(-1.0))k=tan(lineA-acos(-1.0));
y=k*(92900000.0-pc.x)+pc.y;
if(y<0)
{
y=-y;
printf("%lf\n",1.0-area());
}
else
printf("%lf\n",area());
}
void begin()
{
float a1 ,a2;
Point p1;
p1.x=92900000.0,p1.y=-432000.0;
a1=(float)acos(3950.0/distan(center,p1));
a2=(float)asin(432000.0/distan(center,p1));
aB=a1+a2;
}
int main()
{
center.x=0.0,center.y=0.0;
begin();
while(scanf("%f",&t)==1)
{
moveA=2.0*t*acos(-1.0)/(24.0*3600.0);
run();
}
return 0;
}
#include<string.h>
#include<math.h>
struct Point
{
float x, y;
};
float t;
float aB;
float moveA;
Point center;
float y;
float distan(Point p1, Point p2)
{
float dis=(float)sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
return dis;
}
float area()
{
float A;
A=(float)(2.0*acos(-1.0)-2.0*(acos(y/432000.0)));
float Area1=A/2.0*432000.0*432000.0;
Area1+=(float)(y*(432000.0*sin(acos(y/432000.0))));
float result=(Area1/(acos(-1.0)*432000.0*432000.0));
if(result<1)
return result;
else
return 1.0;
}
void run()
{
float A=aB-moveA;
Point pc;
pc.x=(float)cos(A)*3950.0;
pc.y=-(float)sin(A)*3950.0;
float lineA=(float)(acos(-1.0)-(A-acos(-1.0)/2.0));
float k=tan(lineA);
if(tan(lineA)>acos(-1.0))k=tan(lineA-acos(-1.0));
y=k*(92900000.0-pc.x)+pc.y;
if(y<0)
{
y=-y;
printf("%lf\n",1.0-area());
}
else
printf("%lf\n",area());
}
void begin()
{
float a1 ,a2;
Point p1;
p1.x=92900000.0,p1.y=-432000.0;
a1=(float)acos(3950.0/distan(center,p1));
a2=(float)asin(432000.0/distan(center,p1));
aB=a1+a2;
}
int main()
{
center.x=0.0,center.y=0.0;
begin();
while(scanf("%f",&t)==1)
{
moveA=2.0*t*acos(-1.0)/(24.0*3600.0);
run();
}
return 0;
}