PersonalCorpus 版 (精华区)

//1Y

//3207 2003/09/01 11:25:25.900 Accepted 0:00.002 64 C++ 2729 - The Solar System 

#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include "ctype.h"
#include "string.h"
#include "memory.h"
#define EPS 1e-14
void main()
{

#ifndef ONLINE_JUDGE
    freopen ("i","r",stdin);freopen ("o","w",stdout);
#endif
    int a1,b1,t1,a2,b2,t,tot=0;
    double x,y,r,p,f,z,i,j,temp;

    while (1) {
        scanf("%d%d%d%d%d%d",&a1,&b1,&t1,&a2,&b2,&t);
        if ((a1==0)&&(b1==0)&&(t1==0)&&(a2==0)&&(b2==0)&&(t==0)) break;
        
        r=(double)a1*(double)a1*(double)a1/(double)t1/(double)t1;
        p=sqrt((double)a2*(double)a2*(double)a2/r); //period
        f=sqrt(a2*a2-b2*b2);
        r=t-floor(t/p)*p;
        r=r*3.1415926535897931*a2*b2/p;

        i=0;j=3.1415926535897931*2;
        while (j-i>EPS) {
            z=(i+j)/2;
            temp=(a2*b2*z-b2*f*sin(z))/2-r;
            if (fabs(temp)<EPS) break;
            if (temp>0) j=z; else i=z;
        }
        x=a2*cos(z);
        y=b2*sin(z);
        printf("Solar System %d: %.3lf %.3lf\n",++tot,x,y);
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.325毫秒