結果
| 問題 |
No.915 Plus Or Multiple Operation
|
| コンテスト | |
| ユーザー |
tko919
|
| 提出日時 | 2019-10-27 00:18:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 978 bytes |
| コンパイル時間 | 1,555 ms |
| コンパイル使用メモリ | 166,164 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-07 03:42:19 |
| 合計ジャッジ時間 | 2,384 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 RE * 2 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end
void solve(){
int a,b,c; scanf("%d%d%d",&a,&b,&c);
if(c==0){
printf("-1\n"); return;
}
ll ans=inf,cnt=0;
while(a){
chmin(ans,cnt+(a+c-2)/(c-1));
if(a%c)a-=a%c; else a/=c; cnt++;
}
printf("%lld\n",ans*b);
}
int main(){
int t; scanf("%d",&t);
rep(rot,0,t)solve();
return 0;
}
tko919