結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー |
![]() |
提出日時 | 2019-10-25 21:34:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 1,739 ms |
コンパイル使用メモリ | 167,392 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-07 03:21:39 |
合計ジャッジ時間 | 2,085 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define all(x) (x).begin(),(x).end()const int mod=1000000007,MAX=100003,INF=1<<30;int main(){int Q;cin>>Q;while(Q){ll A,B,C;cin>>A>>B>>C;if(C==1){cout<<-1<<endl;}else{ll cnt=0;while(A){if((C-1)*2>=A){A-=(C-1);A=max(0LL,A);cnt++;}else if(A%C){A-=A%C;cnt++;}else{A/=C;cnt++;}//cout<<A<<endl;}cout<<B*cnt<<endl;}Q--;}}