Swimming

/*


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


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_高金

*/


 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 }


Swimming,布布扣,bubuko.com

时间: 2024-08-24 06:18:55

Swimming的相关文章

【Virtual Judge】E - 特别水的题5-Wilbur and Swimming Pool

Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the a

CodeForces 596A Wilbur and Swimming Pool

水题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; struct X { int x,y; }s[5],tmp[5]; int n; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d",&am

c#抽象类和接口的简单举例

1. 个性大于共性. 2. 差异较大的个性间具有某些相同的行为. 3. 相同行为的实现方式有较大区别. 给你三个对象,分别是鲫鱼.鲤鱼.金鱼,仍然让你设计基类来概括它们之间的联系,那么你第一个意识到的肯定是它们都属于鱼类,其次是他们游泳的方式可能稍有差异,这时就应当使用抽象基类而不是接口,对比着上面的例子,原因有三条: interface ISwim { void Swim(); } public class Person : ISwim { public void Swim() { //Swi

POJ 2253 Frogger(最小最大距离)

题意  给你n个点的坐标  求第1个点到第2个点的所有路径中两点间最大距离的最小值 很水的floyd咯 #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; const int N=205; double d[N][N]; int x[N],y[N],n; void floyd() { for(int k=1;k<=n;++

C#OOP之八 继承 接口和抽象类

继承 在现实生活中有所谓的"种瓜得瓜.种豆得豆"的说法,在生物学概念上就是"遗传"的概念,在面向对象中"继承"就类似于生物学中的遗传,通过继承,可以更好的实现代码的重用(复用,多次使用的意思).增加扩展性.简化代码等. 下面是现实生活中的引用: 定义与使用继承 继承一次最常用的就是通过合法程序(比如遗嘱)从别人那里接受财产或爵位等,有点类似于世袭制. 另外一个含义,是人从父母那里继承一些特征,如果孩子从父母继承的身高.相貌等特征.那么在什么情况下

redux 初步理解

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #454545 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #454545; min-height: 14.0px } span.s1 { font: 12.0px "PingFang SC" } 派发一个 action 给 reducer, r

java设计模式(六)策略模式

策略模式定义了一系列的算法,并将每一个算法封装起来,而且使它们可以相互替换,让算法独立于使用它的客户而独立变化,具体应用场景如第三方支付对接不同银行的算法. 要点:1)抽象策略角色    2)具体策略角色:包装相关算法和行为 3)环境角色:持有一个策略类的引用,最终给客户端调用 1.抽象策略接口 public interface SwimmingStratege { public void swimming(); } 2.具体策略角色SwimmingWithFoot public class S

ural 2017 Best of a bad lot

2017. Best of a bad lot Time limit: 1.0 secondMemory limit: 64 MB A cruise liner hasn’t moved away from the land even for three miles when it became apparent that somebody has drowned one of the stewards in the swimming pool. The captain promised to

Inverted sentences

And ever has it been that love knows not its own depth until the hour of separation. 除非临到了别离的时候,爱永远不会知道自己的深浅. 这是个倒装句,因为ever位于句首,句子要倒装,it是形式主语,has been是谓语,that从句是真正的主语从句,until后为状语 倒装句 在英语中,主语和谓语的语序通常是主语在前,谓语在后.这类语序被称为“自然语序”.但有时为了强调句子的某一部分,或由于其它诸如语法结构或