Problem:


マンハッタンでは，道路がx 座標またはy 座標が整数のところに通っている．すぬけ君の家とすめけ君の家はどちらも道路上にあり，直線距離(ユークリッド距離) はちょうど d である．すぬけ君の家からすめけ君の家まで道路に沿って移動するときの最短距離として考えられる最大値を求めよ．

Constraints

 0 < d ≤ 10

d は小数点以下ちょうど三桁まで与えられる

Input

d

Output

答えを一行に出力せよ．絶対誤差または相対誤差が 10&minus;9 以下のとき正答と判定される．

Sample Input 1

1.000

Sample Output 1

2.000000000000

Sample Input 2

2.345

Sample Output 2

3.316330803765



Sample input:
1.000


Sample output:
2.000000000000

Submission status: Wrong Answer

Solution code:
import math
d = float(raw_input())
for x in xrange(1, 11):
    if x <= d <= math.sqrt(x ** 2 + 1):
        print "%.10f" % (d + 1.0)
        break
else:
    print "%.10f" % (math.sqrt(2) * d)

Submission status: Wrong Answer

Solution code:
import math
d = float(raw_input())
for x in xrange(1, 11):
    if x <= d <= math.sqrt(x ** 2 + 1):
        print "%.10f" % (d + 1.0)
        break
else:
    if d < 1.0:
        print d
    else:
        print "%.10f" % (math.sqrt(2) * d)

Submission status: Wrong Answer

Solution code:
import math
d = float(raw_input())
ans = math.sqrt(2) * d
for x in xrange(1, 11):
    if x * x <= d * d <= x * 2 + 1:
        ans = max(ans, d + 1.0)
print "%.10f" % ans

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = F()
        nn = n**2
        r = n
        if n % 1 == 0:
            r = n + 1
        for i in range(11):
            if n < i:
                break
            t = nn - i**2
            tt = t ** 0.5
            if tt < 0.5:
                tt = 0.5 + (tt-0.5)
            tr = i + tt
            if r < tr:
                r = tr

        tr = n / (2**0.5) * 2
        if r < tr:
            r = tr

        rr.append('{:0.10f}'.format(r))
        break

    return '\n'.join(map(str, rr))


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = F()
        nn = n**2
        r = n
        if n % 1 == 0:
            r = n + 1

        tr = n / (2**0.5) * 2
        if r < tr:
            r = tr

        rr.append('{:0.10f}'.format(r))
        break

    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
import math
d = float(raw_input())
ans = math.sqrt(2) * d
for x in xrange(1, 11):
    if x * x <= d * d <= x * 2 + 1:
        ans = max(ans, x + 1)
print "%.10f" % ans

Submission status: Accepted

Solution code:
import math
n=float(input())
print(int(n)+1 if n*math.sqrt(2)<int(n)+1 else n*math.sqrt(2))

Submission status: Accepted

Solution code:
n=float(input())
print(int(n)+1 if n*2**0.5<int(n)+1 else n*2**0.5)

Submission status: Accepted

Solution code:
n=float(input())
print(int(n)+1 if n*2**0.5<n//1+1 else n*2**0.5)

Submission status: Accepted

Solution code:
n=float(input())
print(n//1+1 if n*2**0.5<n//1+1 else n*2**0.5)

Submission status: Accepted

Solution code:
d = float(input())
ans = d * pow(2, 0.5)
for i in range(1, 11):
    if i <= d <= pow(1 + i ** 2, 0.5):
        ans = max(ans, i + 1)
print("{:.020f}".format(ans))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = F()
    nn = n**2
    r = n * (2**0.5)
    for i in range(int(n)+1):
        kk = nn - i**2
        if kk < 0:
            break
        k = kk ** 0.5
        tr = i + k
        if k < 1:
            tr += 1-k
        if r < tr:
            r = tr

    return r


print(main())

Submission status: Accepted

Solution code:
d=float(input());print(max(int(d)+1,d*2**0.5))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
d = float(input())
ans = max(2**0.5 * d, int(d) + 1)
print(ans)

Submission status: Runtime Error

Solution code:
import math
d = float(raw_input())
res = math.sqrt(2) * d
for x in xrange(1, 11):
    if x * x <= d * d <= x * 2 + 1:
        ans = max(ans, d + 1.0)
print "%.10f" % ans