結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,256 KB
testcase_01 AC 33 ms
10,624 KB
testcase_02 AC 32 ms
10,752 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):
    high = K * max(A, B)
    low = 1  
    
    while low < high:
        mid = (low + high) // 2
        count = mid - (mid // A) - (mid // B) + (mid // lcm(A, B))

        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