結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー |
|
提出日時 | 2021-11-01 02:59:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 518 bytes |
コンパイル時間 | 2,204 ms |
コンパイル使用メモリ | 191,292 KB |
最終ジャッジ日時 | 2025-01-25 10:13:53 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); long long int a,b,c; int q; cin >> q; while(q--) { long long int res = 0; cin >> a >> b >> c; if(c==1) { cout << -1 << '\n'; continue; } while(a > 0) { if(a >= c && a < 2*c) { res += b; a-=(c-1); } else { if(a%c!=0) { res += b; a -= (a%c); } else { a/=c; res+=b; } } } cout << res << '\n'; } return 0; }