結果

問題 No.2526 Kth Not-divisible Number
ユーザー ntudantuda
提出日時 2023-11-04 11:57:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 360 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 76,236 KB
最終ジャッジ日時 2023-11-04 11:57:27
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 37 ms
53,724 KB
testcase_02 AC 37 ms
53,724 KB
testcase_03 AC 675 ms
76,192 KB
testcase_04 AC 669 ms
76,228 KB
testcase_05 AC 687 ms
76,200 KB
testcase_06 AC 668 ms
76,236 KB
testcase_07 AC 673 ms
76,192 KB
testcase_08 AC 633 ms
76,192 KB
testcase_09 AC 642 ms
76,176 KB
testcase_10 AC 710 ms
76,180 KB
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import lcm

for _ in range(int(input())):
    A,B,K = map(int,input().split())
    C = lcm(A,B)

    lb = K
    ub = K * 10

    while ub - lb > 1:
        mid = (ub + lb) // 2
        if mid - mid//A - mid//B + mid//C >= K:
            ub = mid
        else:
            lb = mid
    while ub % A == 0 or ub % B == 0:
        ub -= 1
    print(ub)

0