結果
| 問題 |
No.2953 Maximum Right Triangle
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-11-08 21:52:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 2,000 ms |
| コード長 | 583 bytes |
| コンパイル時間 | 429 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 62,208 KB |
| 最終ジャッジ日時 | 2024-11-08 21:52:37 |
| 合計ジャッジ時間 | 1,319 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 |
ソースコード
import math
def Bisect_Int(ok,ng,is_ok):
while abs(ok-ng)>1:
mid=(ok+ng)//2
if is_ok(mid):
ok=mid
else:
ng=mid
return ok
T=int(input())
for t in range(T):
D,X,Y=map(int,input().split())
g=math.gcd(X,Y)
x=X//g
y=Y//g
def is_ok(c):
return X+c*y<=D and Y-c*x>=0
inf=1<<30
r=Bisect_Int(-inf,inf,is_ok)
def is_ok(c):
return X+c*y>=0 and Y-c*x<=D
l=Bisect_Int(inf,-inf,is_ok)
if l>r or l==r==0:
ans=0
else:
ans=max(abs(l),abs(r))*(X*x+Y*y)
print(ans)
vwxyz