結果

問題 No.2526 Kth Not-divisible Number
ユーザー LanatusLanatus
提出日時 2023-11-03 22:19:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,002 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 76,048 KB
最終ジャッジ日時 2023-11-03 22:19:45
合計ジャッジ時間 9,713 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,672 KB
testcase_01 AC 33 ms
53,672 KB
testcase_02 AC 32 ms
53,672 KB
testcase_03 AC 998 ms
76,036 KB
testcase_04 AC 998 ms
76,032 KB
testcase_05 AC 973 ms
76,044 KB
testcase_06 AC 999 ms
76,036 KB
testcase_07 AC 1,002 ms
76,032 KB
testcase_08 AC 748 ms
76,048 KB
testcase_09 AC 671 ms
76,040 KB
testcase_10 AC 796 ms
76,040 KB
testcase_11 AC 662 ms
76,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

t = int(input())
  
def f(a, b, k, x):
  sum = 0

  sum += x // a
  sum += x // b
  sum -= x // math.lcm(a, b)

  return (x - sum >= k)

for _ in range(t):
  a, b, k = map(int, input().split())

  l = 0
  r = int(5e18)
  while r - l > 1:
    m = (l + r) // 2
    if f(a, b, k, m):
      r = m
    else:
      l = m
  
  print(r)


0