結果

問題 No.2526 Kth Not-divisible Number
ユーザー wgrapewgrape
提出日時 2023-12-13 09:50:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,024 KB
最終ジャッジ日時 2023-12-13 09:50:32
合計ジャッジ時間 10,074 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,588 KB
testcase_01 WA -
testcase_02 AC 37 ms
53,588 KB
testcase_03 AC 1,059 ms
76,024 KB
testcase_04 AC 1,052 ms
76,024 KB
testcase_05 AC 1,065 ms
76,024 KB
testcase_06 AC 1,064 ms
76,024 KB
testcase_07 AC 1,050 ms
76,024 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = K * 2
    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