結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー |
![]() |
提出日時 | 2019-10-25 21:56:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 1,716 ms |
コンパイル使用メモリ | 166,548 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 03:27:51 |
合計ジャッジ時間 | 2,055 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long int ll;constexpr int INF = INT_MAX;constexpr int MAX_N = int(1e5)+5;int main() {int q;cin >> q;for(int i=0;i<q;i++){ll a, b, c, ans = 0;cin >> a >> b >> c;if(c == 1){cout << -1 << endl;continue;}while(a > 0){if(a<2*c-1){ans += b*((a-1)/(c-1)+1);a = 0;}else{if(a%c) ans += b;ans += b;a /= c;}}cout << ans << endl;}return 0;}