結果

問題 No.2526 Kth Not-divisible Number
ユーザー hir355hir355
提出日時 2023-11-03 22:22:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,157 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 76,128 KB
最終ジャッジ日時 2023-11-03 22:22:52
合計ジャッジ時間 10,780 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,736 KB
testcase_01 AC 37 ms
53,736 KB
testcase_02 AC 37 ms
53,736 KB
testcase_03 AC 1,157 ms
76,128 KB
testcase_04 AC 1,152 ms
76,128 KB
testcase_05 AC 1,150 ms
76,128 KB
testcase_06 AC 1,127 ms
76,128 KB
testcase_07 AC 1,128 ms
76,128 KB
testcase_08 AC 862 ms
76,128 KB
testcase_09 AC 765 ms
76,128 KB
testcase_10 AC 911 ms
76,128 KB
testcase_11 AC 770 ms
76,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
t = int(input())
for i in range(t):
    a, b, k = map(int, input().split())
    l, r = 0, 10 ** 19 + 1
    while r - l > 1:
        m = (l + r) // 2
        x = m - (m // a + m // b - m // (a * b // gcd(a, b)))
        if x >= k:
            r = m
        else:
            l = m
    print(r)
0