結果
| 問題 | No.915 Plus Or Multiple Operation |
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2019-10-25 22:19:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 837 bytes |
| コンパイル時間 | 2,322 ms |
| コンパイル使用メモリ | 194,836 KB |
| 最終ジャッジ日時 | 2025-01-08 01:21:46 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 2 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
Int q;
cin>>q;
while(q--){
Int a,b,c;
cin>>a>>b>>c;
if(c==1){
cout<<(a*b)<<endl;
continue;
}
vector<Int> vs;
while(a){
vs.emplace_back(a%c);
a/=c;
}
reverse(vs.begin(),vs.end());
Int m=vs.size();
//for(Int i=0;i<m;i++) cout<<i<<":"<<vs[i]<<endl;
Int cnt=0;
for(Int i=0;i<m;i++){
if(i!=0) cnt++;
if(vs[i]!=1||i+1>=m||vs[i+1]==0||vs[i+1]==c-1){
if(vs[i]) cnt++;
continue;
}
if(i!=0) cnt++;
i++;cnt++;cnt++;
}
cout<<cnt*b<<endl;
}
return 0;
}
beet