結果
| 問題 |
No.2526 Kth Not-divisible Number
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-08-09 06:10:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 714 ms / 2,000 ms |
| コード長 | 468 bytes |
| コンパイル時間 | 653 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 77,824 KB |
| 最終ジャッジ日時 | 2024-08-09 06:10:55 |
| 合計ジャッジ時間 | 7,934 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
import math
def LCM(n,m):
if n or m:
return abs(n)*abs(m)//math.gcd(n,m)
return 0
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):
A,B,K=map(int,input().split())
lcm=LCM(A,B)
def is_ok(x):
return x-1-(x-1)//A-(x-1)//B+(x-1)//lcm<K
ans=Bisect_Int(1,K*3+3,is_ok)
print(ans)
vwxyz