首页 > 其他 > 详细

Swimming

时间:2014-05-22 14:14:07      阅读:427      评论:0      收藏:0      [点我收藏+]

/*

Swimming

时间限制:1000 ms  |  内存限制:65535 KB
难度:1
 
描述
Peipei likes swimming. Strange that he always swims from a coner to the counter corner in
the way bellow(that means Peipei must swim to the other site and back, then go to the other site
corner),  as is  shown in Figure  P1
bubuko.com,布布扣
Figure P1    The pool and the way of swimming
Now the problem comes to you is: what is the least distance peipei has to swim ?
 
输入
There are several test cases, one line for each case. For each line,There are two number of
positive integers of the width and height. Width and Height are between l and 10 000, inclusively.
Input is ended with Width = Height = 0.
输出
Output each least distance in a single line, round the result to the nearest integer, e.g. 1.3
rounds to 1, 1.8 rounds to 2, 123.456 rounds to 123, 123.5 rounds to 124, 124.5 rounds to 125.
样例输入
1 1
1 2
2 1
0 0
样例输出
3
6
4
来源
《国际大学生程序设计竞赛例题解 》
上传者
TC_高金
*/
bubuko.com,布布扣
 1 #include<stdio.h>
 2 #include<math.h>
 3 int main()
 4 {
 5     double w, h;
 6     while( scanf ("%lf%lf", &w, &h) != EOF && w && h )
 7     {
 8         double x, y;
 9         x = w * 2 / 3;
10         y = 2*sqrt(x*x/4.0+h*h) + sqrt( (w/ 3.0) * (w/ 3.0 ) + h*h );
11         printf("%.0lf\n", y);
12     }
13     return 0;
14 }
bubuko.com,布布扣

 

Swimming,布布扣,bubuko.com

Swimming

原文:http://www.cnblogs.com/a604378578/p/3744897.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!