现在的位置: 首页 > 综合 > 正文

hdu 3940

2013年08月15日 ⁄ 综合 ⁄ 共 1225字 ⁄ 字号 评论关闭

#include<stdio.h>
#include<math.h>
#include<string.h>
double first(double vx,double vy,double h) {
    return vx*(vy+sqrt(vy*vy+19.6*h))/9.8;
}
double nowh(double h,double vy,double t) {
    return h+vy*t-4.9*t*t;
}
int main() {
    double  k,h,vx,vy,v1,v2,v3,h1,h2,t;
    char s[30];
    while(scanf("%lf%s",&h,s)!=EOF) {
        if(strcmp(s,"Red")==0) {
            scanf("%lf%lf",&vx,&vy);
            printf("%.3f\n",first(vx,vy,h));
            continue;
        }
            if(strcmp(s,"Yellow")==0) {
            scanf("%lf%lf%lf",&vx,&vy,&t);
          if(first(vx,vy,h)<vx*t) {
             printf("%.3f\n",first(vx,vy,h));
             continue;
    }
        h1=nowh(h,vy,t);
        h2=vx*t;
        vy=vy-9.8*t;
        printf("%.3f\n",h2+first(2*vx,2*vy,h1));
        continue;
            }
            if(strcmp(s,"Blue")==0){
                scanf("%lf%lf%lf%lf%lf%lf",&vx,&vy,&t,&v1,&v2,&v3);
                if(first(vx,vy,h)<vx*t) {
                printf("%.3f\n",first(vx,vy,h));
                continue;
                }
                 h1=nowh(h,vy,t);
                 h2=vx*t;
                 vy=vy-9.8*t;
    printf("%.3f %.3f %.3f\n",h2+first(v1,vy,h1),h2+first(v2,vy,h1),h2+first(v3,vy,h1));
            }
    }
    return 0;
}

//一个博客地址帮助你理解http://blog.sina.com.cn/s/blog_c0519a300101dr2w.html

抱歉!评论已关闭.