結果
問題 |
No.915 Plus Or Multiple Operation
|
ユーザー |
![]() |
提出日時 | 2020-11-13 16:12:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 467 bytes |
コンパイル時間 | 597 ms |
コンパイル使用メモリ | 65,292 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-07 03:51:54 |
合計ジャッジ時間 | 1,228 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <iostream> using namespace std; int main(){ int Q; cin >> Q; for (int i = 0; i < Q; i++){ int A, B, C; cin >> A >> B >> C; if (C == 1){ cout << -1 << endl; } else { long long ans = 0; while (A > 0){ if (C >= 3 && C < A && A <= C * 2 - 2){ ans += B * 2; break; } if (A % C != 0){ ans += B; A -= A % C; } if (A == 0){ break; } ans += B; A /= C; } cout << ans << endl; } } }