結果

問題 No.2526 Kth Not-divisible Number
ユーザー 👑 rin204rin204
提出日時 2023-11-03 21:35:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 663 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 76,964 KB
最終ジャッジ日時 2023-11-03 21:35:26
合計ジャッジ時間 7,096 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,760 KB
testcase_01 AC 33 ms
53,760 KB
testcase_02 AC 35 ms
53,760 KB
testcase_03 AC 622 ms
76,932 KB
testcase_04 AC 617 ms
76,924 KB
testcase_05 AC 610 ms
76,928 KB
testcase_06 AC 607 ms
76,928 KB
testcase_07 AC 655 ms
76,932 KB
testcase_08 AC 602 ms
76,928 KB
testcase_09 AC 663 ms
76,932 KB
testcase_10 AC 635 ms
76,924 KB
testcase_11 AC 357 ms
76,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd


def solve(a, b, k):
    l = 0
    r = k * 7
    lc = a * b // gcd(a, b)
    while r - l > 1:
        m = (l + r) // 2
        c = m // a + m // b - m // lc
        if m - c >= k:
            r = m
        else:
            l = m

    return r


for _ in range(int(input())):
    print(solve(*map(int, input().split())))
0