結果

問題 No.2526 Kth Not-divisible Number
ユーザー wgrapewgrape
提出日時 2023-12-13 09:46:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 489 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 83,792 KB
最終ジャッジ日時 2023-12-13 09:46:45
合計ジャッジ時間 6,006 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

T = int(input())
import math
def is_ok(x,a,b,k): # xに対して、aでもbでも割り切れない数がk個以上存在すればTrue
    g = math.gcd(a, b)
    L = a // g * b
    cnt = x - (x // a) - (x // b) + (x // L)
    return cnt >= k

for _ in range(T):
    A,B,K = map(int,input().split())
    ok = 10 ** 20
    ng = 0
    while abs(ok - ng) > 1:
        mid = abs(ok + ng) // 2
        if is_ok(mid, A, B, K):
            ok = mid
        else:
            ng = mid
    print(ok)
0