/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 14ms 3.098 MiB
#2 Accepted 46ms 3.02 MiB
#3 Accepted 162ms 3.105 MiB
#4 Accepted 52ms 3.137 MiB
#5 Accepted 98ms 3.129 MiB
#6 Accepted 16ms 3.113 MiB
#7 Accepted 15ms 3.09 MiB
#8 Accepted 14ms 3.105 MiB
#9 Accepted 1239ms 3.344 MiB
#10 Accepted 970ms 3.086 MiB
#11 Accepted 15ms 3.121 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-11-11 03:43:29
Judged By
Score
100
Total Time
1239ms
Peak Memory
3.344 MiB