/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 14ms 2.777 MiB
#2 Accepted 56ms 2.758 MiB
#3 Accepted 202ms 2.719 MiB
#4 Accepted 44ms 2.777 MiB
#5 Accepted 77ms 2.777 MiB
#6 Accepted 12ms 2.777 MiB
#7 Accepted 9ms 2.777 MiB
#8 Accepted 9ms 2.777 MiB
#9 Accepted 1068ms 2.777 MiB
#10 Accepted 740ms 2.777 MiB
#11 Accepted 10ms 2.777 MiB

Code

import math as m
t = int(input())
for _ in range(t):
    #x = list(map(int, input().split()))
    B = int(input())
    sqB = B*B
    limit = int((sqB/2)+5)
    ans = -1
    for h in range(limit,1,-1):
        sqH = sqB+h*h
        H = int(m.sqrt(sqH))
        if(H*H==sqH):
            ans = H+h+B
            break
    print(ans)
    

        

Information

Submit By
Type
Submission
Problem
P1027 Right triangle
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-15 10:30:50
Judged At
2024-02-14 01:06:32
Judged By
Score
100
Total Time
1068ms
Peak Memory
2.777 MiB