結果

問題 No.2526 Kth Not-divisible Number
ユーザー 2000 Ekiben2000 Ekiben
提出日時 2024-06-30 17:50:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 462 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 17,820 KB
最終ジャッジ日時 2024-06-30 17:50:16
合計ジャッジ時間 4,377 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
17,820 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 32 ms
10,880 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def lcm(a, b):
    return a * b // math.gcd(a, b)

def kth(A, B, K):
    LCM_AB = lcm(A, B)
    low = K
    high = K * max(A, B)

    while low < high:
        mid = (low + high) // 2
        count = mid - (mid // A) - (mid // B) + (mid // LCM_AB)

        if count < K:
            low = mid + 1
        else:
            high = mid

    return low
T = int(input())
for _ in range(T):
    A, B, K = map(int, input().split())
    print(kth(A, B, K))
0