結果
問題 |
No.915 Plus Or Multiple Operation
|
ユーザー |
![]() |
提出日時 | 2019-10-25 23:19:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 425 bytes |
コンパイル時間 | 619 ms |
コンパイル使用メモリ | 69,580 KB |
最終ジャッジ日時 | 2025-01-08 01:46:53 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 4 |
ソースコード
#include <iostream> #include <vector> using namespace std; typedef long long ll; ll solve(ll a,ll b,ll c){ if(c==1) return a*b; if(a<c) return b; if(a==c) return 2*b; ll r = a%c,k = a/c; ll cnt = (r!=0) + (k!=1); return cnt*b+solve(k,b,c); } int main(){ int Q; cin >> Q; for(int i=0;i<Q;i++){ ll a,b,c; cin >> a >> b >> c; cout << solve(a,b,c) << endl; } }