結果

問題 No.2953 Maximum Right Triangle
ユーザー flippergo
提出日時 2025-01-13 17:54:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 573 bytes
コンパイル時間 2,606 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 75,264 KB
最終ジャッジ日時 2025-01-13 17:54:58
合計ジャッジ時間 3,886 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
T = int(input())
for _ in range(T):
    D,x,y = map(int,input().split())
    if y==0:
        print(x*D)
    else:
        d = gcd(x,y)
        n = y//d
        m = x//d
        k1 = min(x//n,(D-y)//m)
        k2 = min((D-x)//n,y//m)
        k = max(k1,k2)
        S2 = (x**2+y**2)*(n**2+m**2)*k**2
        high = S2
        low = 0
        while high-low>1:
            mid = (high+low)//2
            if mid**2<=S2:
                low = mid
            else:
                high = mid
        print(low)
0