結果

問題 No.2526 Kth Not-divisible Number
ユーザー なえしら
提出日時 2023-11-28 18:44:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,976 ms / 2,000 ms
コード長 364 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 82,692 KB
実行使用メモリ 84,336 KB
最終ジャッジ日時 2024-09-26 13:02:26
合計ジャッジ時間 19,929 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import lcm
import sys
input = sys.stdin.readline

def is_ok(md):
  cnt = md - md//A - md//B + md//L
  return cnt >= K
def bis(ok, ng):
  while abs(ok - ng) > 1:
    md = (ng + ok) // 2
    if is_ok(md): ok = md
    else: ng = md
  return ok

for _ in range(T := int(input())):
  A, B, K = map(int, input().split())
  L = lcm(A, B)
  print(bis(10**19, 0))
0