結果

問題 No.2526 Kth Not-divisible Number
ユーザー naesiranaesira
提出日時 2023-11-03 23:32:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 620 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 76,020 KB
最終ジャッジ日時 2023-11-03 23:32:53
合計ジャッジ時間 7,411 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,672 KB
testcase_01 AC 32 ms
53,672 KB
testcase_02 AC 32 ms
53,672 KB
testcase_03 AC 600 ms
76,016 KB
testcase_04 AC 586 ms
76,008 KB
testcase_05 AC 599 ms
76,012 KB
testcase_06 AC 590 ms
76,020 KB
testcase_07 AC 620 ms
76,016 KB
testcase_08 AC 618 ms
76,016 KB
testcase_09 AC 582 ms
76,016 KB
testcase_10 AC 572 ms
76,016 KB
testcase_11 AC 525 ms
76,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

T = int(input())
for _ in range(T):
  A, B, K = map(int, input().split())
  L = A // gcd(A, B) * B

  ng, ok = 0, 10**19
  while ok - ng > 1:
    md = (ng + ok) // 2
    cnt = md - md//A - md//B + md//L
    if cnt < K: ng = md
    else: ok = md
  print(ok)
0