結果
問題 |
No.2526 Kth Not-divisible Number
|
ユーザー |
![]() |
提出日時 | 2023-04-02 19:00:57 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 699 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 86,016 KB |
最終ジャッジ日時 | 2024-09-25 19:00:03 |
合計ジャッジ時間 | 7,060 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 |
other | -- * 11 |
ソースコード
import math def gcd(a, b): return math.gcd(a, b) def judge(X, A, B, C, K): return X - (X//A + X//B - X//C) <= K def solve(): A, B, K = map(int, input().split()) assert A != B assert 2 <= A <= 1e9 assert 2 <= B <= 1e9 assert 1 <= K <= 1e18 C = A * B // gcd(A, B) l = 0 r = 4e18 while r - l > 1: c = (l + r) // 2 if judge(c, A, B, C, K): l = c else: r = c l = int(l) mi = max(1, l - 5) for X in range(mi, l + 1): if X - (X//A + X//B - X//C) == K and X % A != 0 and X % B != 0: print(X) return assert False T = int(input()) for _ in range(T): solve()