結果
問題 | No.2526 Kth Not-divisible Number |
ユーザー |
![]() |
提出日時 | 2023-11-03 21:56:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 381 ms / 2,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 76,800 KB |
最終ジャッジ日時 | 2024-09-25 20:10:49 |
合計ジャッジ時間 | 4,614 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
import sys input = sys.stdin.readline from math import lcm T=int(input()) for tests in range(T): A,B,K=map(int,input().split()) LCM=lcm(A,B) # 1~LCM中に、LCM/A+LCM/B-1個が条件を満たさない k=LCM//A+LCM//B-1 #print(LCM,k) rest=LCM-k x=K//rest ANS=x*LCM K-=rest*x #print(ANS,K) if K==0: print(ANS-1) continue OK=LCM NG=0 while OK>NG+1: mid=(OK+NG)//2 if mid-(mid//A)-(mid//B)>=K: OK=mid else: NG=mid print(ANS+OK)