結果
問題 |
No.915 Plus Or Multiple Operation
|
ユーザー |
![]() |
提出日時 | 2019-10-25 22:11:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 631 bytes |
コンパイル時間 | 1,761 ms |
コンパイル使用メモリ | 167,908 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-11-07 03:32:09 |
合計ジャッジ時間 | 2,067 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 2 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=x;i<y;i++) #define range(a) (a).begin(),(a).end() #define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl; #define pprint(A,m,n) rep(j,0,m){print(A[j],n);} const long mod=1e9+7; const int size=1e5; const int INF=1e9; int main(){ int Q;cin>>Q; long a,b,c; rep(i,0,Q){ cin>>a>>b>>c; long res=0; if(c==1){ cout<<a*b<<endl; continue; } while(a>0){ if(a<c){ res++; break; } else if(a<2*c-1){ res+=2; break; } else if(a%c==0) res++; else res+=2; a=a/c; }cout<<res*b<<endl; } }