結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
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())

while T > 0:
    a, b, k = map(int, input().split())
    
    l = 1
    r = 10 ** 25
    
    while r - l > 1:
        mid = (l + r) // 2
        sum = 0
        sum += mid // a
        sum += mid // b
        sum -= mid // (a * b // math.gcd(a, b))
        
        if sum >= k:
            r = mid
        else:
            l = mid
    
    print(r)
    T -= 1
0