Problem:


四角すいの表面積

1 辺が x の正方形を底面とする、高さ h の四角すいの表面積 S を出力するプログラムを作成して下さい。ただし、頂点と底面の中心を結ぶ線分は底面と直交しているとします。また、 x、h は 100 以下の正の整数とします。

Input

複数のデータセットが与えられます。各データセットは以下の形式で与えられます。

x
h

x, h が共に 0 のとき入力の終了を示します。

Output

各データセットごとに、S（実数）を１行に出力して下さい。出力は0.00001以下の誤差を含んでもよい。

Sample Input

6
4
7
9
0
0

Output for the Sample Input

96.000000
184.192455 



Sample input:
6
4
7
9
0
0


Sample output:
96.000000
184.192455

Submission status: Wrong Answer

Solution code:
while True:
 x = input()
 h = input()
 if x == 0 and h == 0:
  break
 print x * x * h / 3.0

Submission status: Wrong Answer

Solution code:
import math

def suicide(x, h):
    r2 = (math.sqrt(2)*x*0.5)**2 + h**2
    t2 = r2 - (0.5*x)**2
    t = math.sqrt(t2)
    S = x*x + 4*(x*t*0.5)
    print S

import sys

x = 0
h = 0
for line in sys.stdin:
    if not line.rstrip() == 0:
        if x == 0:
            x = int(line.rstrip())
        elif x:
            h = int(line.rstrip())
        if x  and h :
            suicide(x, h)
            x = 0

Submission status: Wrong Answer

Solution code:
import math 
if __name__=="__main__":
    while True:
        x=int(raw_input())
        h=int(raw_input())
        if x==0 and h==0 :
            break
        tra=math.sqrt((x/2)**2+h**2)
        print x**2+tra*x/2*4

Submission status: Wrong Answer

Solution code:
def piramid(x,h):
    import math
    a = math.sqrt((x/2)**2 + h**2)
    b = (x*a)/2
    c = x**2 + 4*b
    return print(c)

Submission status: Wrong Answer

Solution code:
import math
x = int(input())
h = int(input())
if x == h == 0:
    S = (x ** 2) + 4(x * (math.sqrt((1 / 2) ** 2 + h ** 2 ))) 
    print(S)

Submission status: Wrong Answer

Solution code:
import math

while True:
    x = float(input())
    if x == 0:
        break
    h = float(input())
    l = math.sqrt(0.025*x**2 + h**2)
    s = x**2 + 2*x*l
    print(s)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

import math


def get_answer(param):
    x = param[0]
    h = param[1]
    return math.sqrt(((x / 2) ** 2) + (h ** 2)) * x * 2 + (x * x)


def main():
    params = []
    while 1:
        x = int(raw_input())
        h = int(raw_input())
        if (x == 0) and (h == 0):
            break
        params.append((x, h))
    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
a = -1
while a != 0:
	a = input()
	h = input()
	print a**2+(a*math.sqrt(a**2+4*h**2)+a*math.sqrt(a**2+4*h**2))/2.0

Submission status: Wrong Answer

Solution code:
import math

a = -1
while a != 0:
	a,h = input(),input()
	print '{0:.6f}'.format(a**2+(a*math.sqrt(a**2+4*h**2)+a*math.sqrt(a**2+4*h**2))/2.0)

Submission status: Wrong Answer

Solution code:
import math

a = -1
while a != 0:
	a = float(raw_input())
	h = float(raw_input())
	print '{0:.6f}'.format(a**2+(a*math.sqrt(a**2+4*h**2)+a*math.sqrt(a**2+4*h**2))/2.0)

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x, h = map(int, raw_input())
        print x**2 + 2*x*math.sqrt(h**2 + (float(x)/2)**2)
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x = int(raw_input())
        h = int(raw_input())
        print x**2 + 2*x*math.sqrt(h**2 + (float(x)/2)**2)
    except:
        break

Submission status: Accepted

Solution code:
while True:
  x, h = int(input()), int(input())
  if x == 0:
    break
  print(x ** 2 + x * (4 * h ** 2 + x ** 2) ** (1 / 2))

Submission status: Accepted

Solution code:
from math import hypot

while True:
    x, h = int(input()), int(input())
    if x == h == 0:
        break
    print(hypot(x/2, h)*x*2+x*x)

Submission status: Accepted

Solution code:
import math
while True:
  a=int(input())
  b=int(input())
  if a==0:
    break
  s=a*a+2*a*(math.sqrt(b*b+(a/2)*(a/2)))
  print(s)

Submission status: Accepted

Solution code:
while 1:
    try:
        x=int(input())
        h=int(input())
        if x==0 and h==0 :break
        print("{:.6f}".format(x**2+(((((x/2)**2)+h**2)**0.5)*x)*2))
    except:break

Submission status: Accepted

Solution code:
while True:
    x = float(input())
    h = float(input())
    if x + h == 0: break
    S = 0
    a = ((x / 2) ** 2 + h ** 2) ** 0.5
    S += x * x
    S += (a * x * 0.5) * 4
    print(S)

Submission status: Accepted

Solution code:
while True:
 x = input()
 h = input()
 if x == 0 and h == 0:
  break
 print "%.6f" % (x * x + ((x / 2.0 * (x / 2.0) + h * h) ** 0.5 * x) * 2)

Submission status: Accepted

Solution code:
while True:
    x,h = input(),input()
    if [x,h] == [0,0]: exit()
    print x*(4*h*h+x*x)**0.5+x*x

Submission status: Accepted

Solution code:
import sys
f = sys.stdin


while True:
    x, h = (int(f.readline()) for i in range(2))
    if x == h == 0:
        break
    triangle_height = (h ** 2 + (x / 2) ** 2) ** 0.5
    s = x ** 2 + 4 * x * triangle_height / 2
    print('{:.6f}'.format(s))

Submission status: Accepted

Solution code:
import math
while True:
    try:
        x=float(input())
        h=float(input())
        if x==0 and h ==0:
            break
        y=h**2+(x/2)**2
        y=math.sqrt(y)
        S=x**2+4*x*y/2
        print "{0:.6f}".format(S)
    except:
        break

Submission status: Accepted

Solution code:
import math

def suicide(x, h):
    r2 = (math.sqrt(2)*x*0.5)**2 + h**2
    t2 = r2 - (0.5*x)**2
    t = math.sqrt(t2)
    S = x*x + 4*(x*t*0.5)
    print S

import sys

x = 0
h = 0
for line in sys.stdin:
    if x == 0:
        x = int(line.rstrip())
    elif x:
        h = int(line.rstrip())
    if x  and h :
        suicide(x, h)
        x = 0
        h = 0

Submission status: Accepted

Solution code:
while True:
    x,y=input(),input()
    if x==0 and y==0: break
    a=float(x)/2
    ans=x*x+2*x*(a*a+y*y)**0.5
    print ans

Submission status: Accepted

Solution code:
while True:
  x = int(input())
  h = int(input())
  if x == h == 0:
    break
  else:
    t = (h**2+(x/2)**2)**(1/2)
    print(x*x+x*t*2)

Submission status: Accepted

Solution code:
while 1:
    x=int(raw_input())
    h=int(raw_input())
    if x==h==0:
        break
    print x*((4*h*h+x*x)**0.5)+x*x

Submission status: Accepted

Solution code:
import math 
if __name__=="__main__":
    while True:
        x=float(raw_input())
        h=float(raw_input())
        if x==0 and h==0 :
            break
        tra=math.sqrt((x/2)**2+h**2)
        ans=x**2+tra*x*2
        print "%5f"%(ans)
     #   print ans

Submission status: Accepted

Solution code:
from math import sqrt
while 1:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0: break
    print("{0:.8f}".format(x*x + 2.0 * x * sqrt(h*h + 1/4.0*x*x)))

Submission status: Accepted

Solution code:
while True:
	x=int(input())
	h=int(input())
	if x==h==0:
		break
	S=x**2+2*x*(h**2+(x**2)/4)**(1/2)
	print(S)

Submission status: Accepted

Solution code:
import math

while True:
    x = float(raw_input())
    h = float(raw_input())
    if x + h == 0:
        break
    l = math.sqrt((x/2)**2+h**2)
    print x**2+2*x*l

Submission status: Accepted

Solution code:
while 1:
    x=int(raw_input())
    h=int(raw_input())
    if x==h==0:
        break
    print x**2+4*(1.0/2*x*(h**2+(x/2.0)**2)**(1.0/2))

Submission status: Accepted

Solution code:
import math
while True:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0:
        break
    tei = x * x
    tor = x * (math.sqrt(h * h + (x / 2) ** 2) * 1 / 2)
    ans = tei + 4 * tor
    print("{0:.6f}".format(ans))

Submission status: Accepted

Solution code:
from math import sqrt
while True:
    x, h = int(input()), int(input())
    if x==h==0: break
    sh = sqrt((x/2)**2 + h**2)
    print((x*x) + sum([sh*x*0.5 for _ in range(4)]))

Submission status: Accepted

Solution code:
while 1:
    x=float(input())
    h=float(input())
    if x==0: break
    print(x*x+2*x*(((x/2)**2)+h*h)**0.5)

Submission status: Accepted

Solution code:
import math
while True:
    x = int(input().strip())
    h = int(input().strip())
    if x==0 and h==0:
        break
    d = math.sqrt((x/2.0)**2 + h**2)
    s = x * d / 2.0 * 4 + x**2
    print(s)

Submission status: Accepted

Solution code:
import math
while True:
    X = float(input())
    H = float(input())
    if X == 0.0:
        break
    ans = 0.0
    ans += X * X
    ans += math.sqrt(H * H + X * X / 4.0) * X * 2
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

for s in sys.stdin:
    x = int(s)
    h = int(input())
    if x == h == 0:
        break

    area = x * x + 2 * x * math.sqrt(h * h + x * x / 4)
    print(area)

Submission status: Accepted

Solution code:
import sys
import math
def main():
    for line in sys.stdin:
        x = int(line)
        h = int(input())

        if x != 0 and h != 0:
            s1 = x * math.sqrt(4 * (h ** 2) + x ** 2)
            s2 = s1 + x ** 2
            print("{:.6f}".format(s2))
        else:
            break

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# Aizu Problem 0073: Surface Area of Quadrangular Pyramid
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    x = int(input())
    h = int(input())
    if x == h == 0:
        break
    h_x = math.sqrt(h**2 + x**2 / 4)
    A = x**2 + 2 * x * h_x
    print("%.6f" % A)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0073

"""
import sys
from sys import stdin
input = stdin.readline


def solve(x, h):
    ans = x * x                 #  ?????¨?????¢???

    diagonal = (x**2 + x**2)**0.5 / 2   #  ?????????????????¢????????´????????????????????????????§??????§????????¢
    oblique = (diagonal**2 + h**2)**0.5 #  ????§???¢?????????
    # ??????????????¬???
    s = (x + oblique + oblique) / 2
    triangle = (s * (s - x) * (s - oblique) * (s - oblique))**0.5 #  ????§???¢ 1????????¢???
    
    triangle *= 4               #  ????§??????????????§???¢???4??¢???????????§?????¨??¨?????¢???????¨????
    ans += triangle
    return ans


def main(args):
    while True:
        x = int(input())
        h = int(input())
        if x == 0 and h == 0:
            break
        result = solve(x, h)
        print('{:.6f}'.format(result))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
import math

while True:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0:
        break

    x = float(x)
    h = float(h)
    y = math.sqrt(h**2 + x**2/4.0)
    print(x**2 + 2.0*x*y)

Submission status: Accepted

Solution code:
import math

while True:
    x = float(input())
    if x == 0:
        break
    h = float(input())
    l = math.sqrt(0.25*x**2 + h**2)
    print(x**2 + 2*x*l)

Submission status: Accepted

Solution code:
while 1:
 x,h=int(input()),int(input())
 if x:print(x*x+((x/2)**2+h**2)**.5*x*2)
 else:break

Submission status: Accepted

Solution code:
while 1:
 x,h=int(input()),int(input())
 if x==0:break
 print(x*x+((x/2)**2+h**2)**.5*x*2)

Submission status: Accepted

Solution code:
for x in iter(input,'0'):
 x=int(x)
 print(x*x+2*x*((x/2)**2+int(input())**2)**.5)

Submission status: Accepted

Solution code:
for x in iter(input,'0'):x=int(x);print(x*x+2*x*((x/2)**2+int(input())**2)**.5)

Submission status: Accepted

Solution code:
while True:
	x, h = map(int, [input(), input()])
	if x == 0 and h == 0:
		break
	print(4 * (h*h+(x/2)*(x/2))**0.5 * x / 2 + x*x)

Submission status: Accepted

Solution code:
import math
while 1:
  x=float(input())
  h=float(input())
  if not x and not h:break
  S=x**2+2*math.sqrt((h**2)*(x**2)+1/4*(x**4))
  print("{0:6f}".format(S))

Submission status: Accepted

Solution code:
# AOJ 0073: Surface Area of Quadrangular Pyramid
# Python3 2018.6.15 bal4u

import math
while True:
	x = int(input())
	if x < 1: break
	h = int(input())
	s = math.sqrt(4*h*h + x*x) + x;
	print(s*x);

Submission status: Accepted

Solution code:
import math
while True:
  a=float(input())
  b=float(input())
  if a == 0 and b ==0: break
  hoge= (a/2)**2+b**2
  hoge=float(math.sqrt(hoge))
  ans=float(a*hoge*2+a*a)
  print "%5f"%(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

import math


def get_answer(param):
    x = float(param[0])
    h = float(param[1])
    temp1 = (x * x)
    temp2 = math.sqrt((x / 2) ** 2 + h ** 2)
    temp3 = x * temp2 * 2
    return temp1 + temp3


def main():
    params = []
    while 1:
        x = int(raw_input())
        h = int(raw_input())
        if (x == 0) and (h == 0):
            break
        params.append((x, h))
    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
    x,h=input()+0.0,input()+0.0
    if (x,h)==(0,0):
        break
    print x*x+2*x*((x/2)**2+h**2)**0.5

Submission status: Accepted

Solution code:
import math

while True:

    a = int(raw_input())
    h = int(raw_input())                                                                                                                                                                                     

    if h == 0 or a == 0:
        break

    print a*math.sqrt(4*h**2+a**2)+a**2

Submission status: Accepted

Solution code:
import math
while 1:
    x=input()
    h=input()
    if x==0==h: break
    print "%.5f"%(x*math.sqrt(4*math.pow(h,2)+pow(x,2))+(math.pow(x,2)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from math import hypot

while True:
    x = int(stdin.readline())
    h = int(stdin.readline())
    if not (x or h):
        break
    print('{:.6f}'.format(x * x + hypot(x, h * 2) * x))

Submission status: Accepted

Solution code:
import math
while True:
    x = int(raw_input())
    h = int(raw_input())
    if x == 0 and h == 0:
        break
    print x**2 + 2*x*math.sqrt(h**2 + (float(x)/2)**2)

Submission status: Accepted

Solution code:
while 1:
    x=input()
    h=input()
    if [x,h]==[0,0]:break
    a=float(x)/2
    s=((a*a+h*h)**0.5*2+x)*x
    print s

Submission status: Accepted

Solution code:
while 1:
    x=input()
    h=input()
    if x==0 and h==0: break
    a=float(x)/2
    s=((a*a+h*h)**0.5 * 2 + x)*x
    print s

Submission status: Accepted

Solution code:
while 1:
    x,h = input(),input()
    if x==0 and h==0: break
    a=float(x)/2
    s=x*x+2*x*(a*a+h*h)**0.5
    print s

Submission status: Accepted

Solution code:
from math import hypot

while 1:
    x, h = input(), input()
    if x == h == 0:
        break
    print hypot(x / 2.0, h) * x * 2 + x ** 2

Submission status: Accepted

Solution code:
import math

while True:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0:
        break

    S = 2*x * math.sqrt(x*x/4 + h*h) + x*x

    print(S)

Submission status: Accepted

Solution code:
import math
while True :
    x = float(input())
    h = float(input())
    if x == 0 and h == 0 :
        break
    
    ans = x**2 + math.sqrt(x**2 + 4 * (h**2)) * x
    print('{:.6f}'.format(ans))

Submission status: Accepted

Solution code:
import math

while True:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0:
        break


    S = 1/2 * x * 4*(1/4 * x**2 + h**2)**0.5 + x**2
    print(S)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    x = int(readline())
    h = int(readline())
    if x == h == 0:
        return False
    write("%.16f\n" % (x*x + x*(x*x + 4*h*h)**.5))
    return True
while solve():
    ...

Submission status: Accepted

Solution code:
import math
while 1:
    x = int(input())
    h = int(input())
    if x == h == 0:
        break

    b = math.sqrt(h * h + x * x / 4) * x / 2
    print(4 * b + x * x)

Submission status: Accepted

Solution code:
import math
if __name__ == '__main__':

	while True:
		try:
			x = int(input())
			h = int(input())

			if x == 0 and h == 0:
				break

			n = math.sqrt(h ** 2 + (x / 2) ** 2) 
			ans = (x ** 2) + (x * n * 0.5) * 4
			print('{:.5f}'.format(ans))

		except EOFError:
			break

Submission status: Accepted

Solution code:
import math
while True:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0: break
    
    h2 = math.sqrt((x/2)*(x/2) + h*h)
    print(float(x*x + 2*x*h2))

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    h=int(input())
    if x==0 and h==0:
        break
    a=x**2+x*(4*h**2+x**2)**(1/2)
    print(a)

Submission status: Accepted

Solution code:
import math
while True:    
    x = float(input())
    h = float(input())
    if x==h==0: break

    f = math.hypot(1/2*x,h)
    S = x**2 + 4*f*x/2
    print(S)

Submission status: Accepted

Solution code:
while True:
  x = int(input())
  h = int(input())
  if x == 0 and h == 0:break
  s = x ** 2 + x * (4 * h ** 2 + x ** 2) ** (1 / 2)
  print(s)

Submission status: Accepted

Solution code:
while True:
  x,h = int(input()),int(input())
  if x == 0:
    break
  print(x**2+x*(4*h**2+x**2) ** (1/2))

Submission status: Accepted

Solution code:
while True:
  x = float(input())
  h = float(input())
  if x == 0:
    break
  print(x*x+2*x*(((x/2)**2)+h*h)**0.5)

Submission status: Accepted

Solution code:
while 1:
    x=float(input())
    h=float(input())
    if x==0: break
    print(x*x+2*x*(((x/2)**2)+h*h)**0.5)

Submission status: Accepted

Solution code:
while 1:
    try:
        x=int(input())
        h=int(input())
        if x==h==0:break
        ans=x**2
        he=(h**2+x**2/4)**0.5
        tri=he*x*0.5
        ans+=tri*4
        print(f"{ans:.7f}")
    except:break

Submission status: Accepted

Solution code:
while(1):
    x,h = [int(input()) for i in range(2)]
    if x == 0 and h == 0:
        break
    x,h = [float(i) for i in [x,h]]
    tot = x**2 + 4*0.5*x*(h**2 + (x/2)**2)**(0.5)
    print("{:.6f}".format(tot))

Submission status: Accepted

Solution code:
import math

while 1:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0:
        break

    a = math.sqrt((x/2)**2 + h**2)

    s = a * x * 2 + x**2
    print(s)

Submission status: Accepted

Solution code:
while True:
    x = float(input())
    h = float(input())
    if x == 0 and h == 0: break
    print("%.6f"%(x**2+x*2*(h**2+(x/2)**2)**0.5))

Submission status: Accepted

Solution code:
from math import sqrt

while True:
    x = float(input())
    h = float(input())
    if x == h == 0: break
    ans = (sqrt(4*h*h + x**2) + x) * x
    print(ans)

Submission status: Accepted

Solution code:
import math

while True:
	try:
		x = input()
		h = input()
		if x == 0 and h == 0:
			break
		else:
			print '%6f' % float(x * math.sqrt(4 * h * h + x * x) + x * x)
	except EOFError:
		break

Submission status: Runtime Error

Solution code:

import math
while True:
    x = int(input())
    h = int(input())
    if x == h == 0:
        break
    S = (x ** 2) + 4(x * (math.sqrt((1 / 2) ** 2 + h ** 2 ))) 

print(S)

Submission status: Runtime Error

Solution code:
import math
x = int(input())
h = int(input())
if x == h == 0:
    break
    S = (x ** 2) + 4(x * (math.sqrt(((1 / 2) * x) ** 2 + h ** 2 ))) 
    print(S)

Submission status: Runtime Error

Solution code:
import math
x = int(input())
h = int(input())
if x == h == 0:
    break
    S = (x ** 2) + 4(x * (math.sqrt((1 / 2) * x ** 2 + h ** 2 ))) 
    print(S)

Submission status: Runtime Error

Solution code:
while 1:
 x,h=int(input()),int(input())
 if x:print(x*x+((x/2)**2+h**2)**.5*x*2)