結果
問題 |
No.915 Plus Or Multiple Operation
|
ユーザー |
|
提出日時 | 2019-10-26 00:09:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 575 ms |
コンパイル使用メモリ | 70,680 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 03:40:40 |
合計ジャッジ時間 | 1,192 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
// ? #include<iostream> #include<vector> using namespace std; typedef long long ll; int main(){ int q; cin >> q; while(q-- > 0){ ll a, b, c; cin >> a >> b >> c; if(c == 1){ cout << -1 << endl; continue; } vector<int> v; while(a){ v.push_back(a%c); a /= c; } int n = v.size(); int op = n; if(n > 1){ int from = n-2; if(v[n-1] == 1 && v[n-2] < c-1){ from = n-3; } while(from >= 0) op += v[from--]>0; } cout << op*b << endl; } return 0; }