結果

問題 No.2526 Kth Not-divisible Number
ユーザー miya145592miya145592
提出日時 2023-11-03 22:09:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 463 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 86,964 KB
最終ジャッジ日時 2023-11-03 22:09:30
合計ジャッジ時間 5,915 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,712 KB
testcase_01 AC 34 ms
53,712 KB
testcase_02 AC 34 ms
53,712 KB
testcase_03 AC 463 ms
86,664 KB
testcase_04 AC 449 ms
86,640 KB
testcase_05 AC 449 ms
86,664 KB
testcase_06 AC 454 ms
86,632 KB
testcase_07 AC 449 ms
86,636 KB
testcase_08 AC 447 ms
86,632 KB
testcase_09 AC 404 ms
86,648 KB
testcase_10 AC 432 ms
86,660 KB
testcase_11 AC 399 ms
86,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys
input = sys.stdin.readline
T = int(input())
ABK = [list(map(int, input().split())) for _ in range(T)]
for a, b, k in ABK:
    g = math.gcd(a, b)
    l = a//g*b

    left = 0
    right = 10**19
    while right-left>1:
        mid = (left+right)//2
        cnt = mid//a + mid//b - mid//(l)
        if mid-cnt>=k:
            right = mid
        else:
            left = mid
    print(right)
0