結果

問題 No.2526 Kth Not-divisible Number
ユーザー naesiranaesira
提出日時 2023-11-28 18:44:08
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 364 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,160 KB
最終ジャッジ日時 2023-11-28 18:44:30
合計ジャッジ時間 21,047 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,588 KB
testcase_01 AC 36 ms
53,588 KB
testcase_02 AC 35 ms
53,588 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 1,830 ms
84,160 KB
権限があれば一括ダウンロードができます

ソースコード

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