首页 > 代码库 > Swimming
Swimming
/*
Swimming
时间限制:1000 ms | 内存限制:65535 KB
难度:1
- 描述
- Peipei likes swimming. Strange that he always swims from a coner to the counter corner inthe way bellow(that means Peipei must swim to the other site and back, then go to the other sitecorner), as is shown in Figure P1
- Figure P1 The pool and the way of swimmingNow 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_高金
- */
-
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 }
-
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。