結果

問題 No.915 Plus Or Multiple Operation
ユーザー soto800soto800
提出日時 2019-10-25 22:56:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 680 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 158,036 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 18:47:34
合計ジャッジ時間 1,852 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 b,c;

lli calc(lli a){
	lli next=0;

	if(c==1)return c*b;

	while(1){
		if(DEBUG)cout<<a<<endl;
		if(a<c){
			next+=b;
			break;
		}
		if(a<=2*(c-1)){
			next+= (2*b);
			break;
		}
		next+=b;
		if(a%c!=0)next+=b;
		a /= c;
	}

	return next;
}
void solve(){
	lli a;
	cin>>a>>b>>c;

	/*逆からやるとよさそう*/
	cout<<calc(a)<<endl;
}

signed main(){

	lli q;
	cin>>q;

	REP(i,0,q)solve();

	return 0;
}
0