結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー |
![]() |
提出日時 | 2023-02-08 22:23:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 439 bytes |
コンパイル時間 | 66 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-06 07:24:10 |
合計ジャッジ時間 | 1,031 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
import sys sys.setrecursionlimit(10**7) from functools import lru_cache @lru_cache(maxsize=None) def f(x, c): if x <= 0: return 0 if x % c == 0: return min(f(x//c, c) + 1, (x + c - 2)//(c - 1)) else: return min(f(x - x % c , c) + 1, (x + c - 2)//(c - 1)) Q = int(input()) for _ in range(Q): A, B, C = map(int, input().split()) if C == 1: print(-1) else: print(f(A, C) * B)