結果

問題 No.2526 Kth Not-divisible Number
ユーザー umimelumimel
提出日時 2023-11-03 21:35:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 403 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 16,760 KB
最終ジャッジ日時 2023-11-03 21:35:16
合計ジャッジ時間 4,375 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,164 KB
testcase_01 WA -
testcase_02 AC 28 ms
10,116 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

T = int(input())
ans = [0]*T

for i in range(T):
    a, b, k = map(int, input().split())
    l = a*b//math.gcd(a, b)
    lo = 1
    hi = 1000000000000000000000
    mid = 0
    while hi-lo>1:
        mid = (lo + hi)//2
        cnt = mid//a + mid//b - mid//l
        if mid-cnt<=k:
            lo = mid
        else:
            hi = mid
    ans[i] = lo

for i in range(T):
    print(ans[i])
0