結果
| 問題 |
No.915 Plus Or Multiple Operation
|
| コンテスト | |
| ユーザー |
leaf_1415
|
| 提出日時 | 2019-10-25 22:30:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 594 bytes |
| コンパイル時間 | 532 ms |
| コンパイル使用メモリ | 63,832 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-07 03:33:39 |
| 合計ジャッジ時間 | 1,077 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long
using namespace std;
llint Q;
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> Q;
llint a, b, c;
for(int q = 0; q < Q; q++){
cin >> a >> b >> c;
if(c == 1){
cout << -1 << endl;
continue;
}
vector<llint> vec;
llint ans = 0;
for(llint t = a; t; t/=c){
ans++;
if(t%c) ans++;
vec.push_back(t%c);
}
ans--;
reverse(vec.begin(), vec.end());
if(vec.size() >= 2 && vec[0] == 1 && vec[1] > 0 && vec[1] <= c-2) ans--;
cout << ans*b << endl;
}
return 0;
}
leaf_1415