結果
| 問題 |
No.1350 2019-6problem
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-06-12 02:30:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 641 bytes |
| コンパイル時間 | 549 ms |
| コンパイル使用メモリ | 82,728 KB |
| 実行使用メモリ | 54,064 KB |
| 最終ジャッジ日時 | 2025-06-12 02:30:26 |
| 合計ジャッジ時間 | 2,662 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
from math import lcm
def bsearch(low: int, high: int, fun, is_complement=False) -> int:
def pred(x: int) -> bool:
return not fun(x) if is_complement else fun(x)
lo = low
hi = high
res = low
while lo <= hi:
m = (lo + hi) // 2
if pred(m):
res = max(res, m)
lo = m + 1
else:
hi = m - 1
return res + 1 if is_complement else res
A, B, K = map(int, input().split())
# K 個以上あるか
def can(m: int) -> bool:
cnt = (m // A) + (m // B) - (m // lcm(A, B))
return cnt >= K
ans = bsearch(1, 1 << 60, can, is_complement=True)
print(ans)
norioc