結果

問題 No.2526 Kth Not-divisible Number
ユーザー naesiranaesira
提出日時 2023-11-28 18:54:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 729 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,044 KB
最終ジャッジ日時 2023-11-28 18:55:05
合計ジャッジ時間 8,653 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,716 KB
testcase_01 AC 41 ms
53,716 KB
testcase_02 AC 37 ms
53,716 KB
testcase_03 AC 687 ms
76,044 KB
testcase_04 AC 727 ms
76,044 KB
testcase_05 AC 684 ms
76,044 KB
testcase_06 AC 729 ms
76,044 KB
testcase_07 AC 703 ms
76,044 KB
testcase_08 AC 668 ms
76,044 KB
testcase_09 AC 672 ms
76,044 KB
testcase_10 AC 683 ms
76,044 KB
testcase_11 AC 629 ms
76,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import lcm

def is_ok(md):
  cnt = md - md//A - md//B + md//L
  return cnt >= K

for _ in range(T := int(input())):
  A, B, K = map(int, input().split())
  L = lcm(A, B)
  
  ng, ok = 0, 10**19
  while abs(ok - ng) > 1:
    md = (ng + ok) // 2
    if is_ok(md): ok = md
    else: ng = md
  
  print(ok)
0