結果
問題 |
No.915 Plus Or Multiple Operation
|
ユーザー |
![]() |
提出日時 | 2019-10-25 22:56:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 680 bytes |
コンパイル時間 | 1,263 ms |
コンパイル使用メモリ | 158,744 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-07 03:37:13 |
合計ジャッジ時間 | 1,792 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 2 |
ソースコード
#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; }