pku 1299 Polar Explorer 简单数学,注意精度

题意:

汽车在(0,r)的位置上,现在在离汽车顺时针角度为z度的地方发生一起车祸,问汽车能否赶到那里。已知汽车开始共有n升油,一升油能跑5米。
注意degree取z,360-z的较小值即可。
直接直接贴代码了。。
 1# include <stdio.h>
 2# include <string.h>
 3# define PI 3.14159
 4# define min(a,b) ((a)<(b)?(a):(b))
 5int main()
 6{
 7    char str[20];
 8    while(1)
 9    {
10       int r,amount,degree;
11       scanf("%s",str);
12       if(!strcmp(str,"ENDOFINPUT")) break;
13       scanf("%d%d%d",&r,&amount,&degree);
14       scanf("%s",str);  
15       double req=2*PI*r/360.0*min(degree,360-degree)*2;
16       if(amount*5.0-req>-1e-8)
17          printf("YES %d\n",(int)(amount-req/5.0+1e-8));
18       else
19           printf("NO %d\n",amount*5);
20       
21    }

22    return 0;
23}

24

posted on 2010-12-07 18:13 yzhw 阅读(193) 评论(0)  编辑 收藏 引用 所属分类: simple problem~


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年12月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

公告

统计系统

留言簿(1)

随笔分类(227)

文章分类(2)

OJ

最新随笔

搜索

积分与排名

最新评论

阅读排行榜