結果

問題 No.2526 Kth Not-divisible Number
ユーザー lloyzlloyz
提出日時 2023-11-04 21:38:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 524 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 81,896 KB
実行使用メモリ 76,688 KB
最終ジャッジ日時 2023-11-04 21:38:29
合計ジャッジ時間 6,724 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,820 KB
testcase_01 AC 37 ms
53,820 KB
testcase_02 AC 37 ms
53,820 KB
testcase_03 AC 492 ms
76,180 KB
testcase_04 AC 493 ms
76,176 KB
testcase_05 AC 488 ms
76,156 KB
testcase_06 AC 524 ms
76,176 KB
testcase_07 AC 491 ms
76,180 KB
testcase_08 AC 497 ms
76,192 KB
testcase_09 AC 449 ms
76,172 KB
testcase_10 AC 478 ms
76,180 KB
testcase_11 AC 423 ms
76,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
import sys
input = sys.stdin.readline

for _ in range(int(input())):
    a, b, k = map(int, input().split())
    lcm_ab = a * b // gcd(a, b)
    l, r = 0, 1 << 63
    while r - l > 1:
        mid = (l + r) // 2
        res = mid - (mid // a + mid // b - mid // lcm_ab)
        if res >= k:
            r = mid
        else:
            l = mid
    print(r)
0