結果
| 問題 | No.915 Plus Or Multiple Operation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-26 00:19:49 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 445 bytes |
| 記録 | |
| コンパイル時間 | 336 ms |
| コンパイル使用メモリ | 73,948 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-05-07 11:58:50 |
| 合計ジャッジ時間 | 1,109 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <iostream>
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;
ll q, a, b, c;
int main() {
cin >> q;
while(q--) {
cin >> a >> b >> c;
if(c == 1) {
cout << -1 << '\n';
continue;
}
ll ans = INF, cnt = 0;
while(a) {
ans = min(ans, cnt + (a + c - 2) / (c - 1));
if(a % c) a -= a % c;
else a /= c;
++cnt;
}
cout << ans * b << '\n';
}
return 0;
}