結果
問題 |
No.2953 Maximum Right Triangle
|
ユーザー |
|
提出日時 | 2025-01-13 17:56:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 607 bytes |
コンパイル時間 | 617 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 75,392 KB |
最終ジャッジ日時 | 2025-01-13 17:56:17 |
合計ジャッジ時間 | 2,037 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 |
ソースコード
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) elif x==0: print(y*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)