結果
| 問題 |
No.915 Plus Or Multiple Operation
|
| コンテスト | |
| ユーザー |
soto800
|
| 提出日時 | 2019-10-25 22:36:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 607 bytes |
| コンパイル時間 | 1,328 ms |
| コンパイル使用メモリ | 160,268 KB |
| 実行使用メモリ | 814,592 KB |
| 最終ジャッジ日時 | 2024-11-07 03:34:55 |
| 合計ジャッジ時間 | 5,457 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | MLE * 1 -- * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
lli calc(lli a,lli b,lli c){
if(a<c)return b;
if(a <= 2*(c-1))return 2*b;
lli next = b;
next += calc(a/c,b,c);
if(a%c!=0)next += calc(a%c,b,c);
return next;
}
void solve(){
lli a,b,c;
cin>>a>>b>>c;
/*逆からやるとよさそう*/
cout<<calc(a,b,c)<<endl;
}
signed main(){
lli q;
cin>>q;
REP(i,0,q)solve();
return 0;
}
soto800