結果
問題 |
No.915 Plus Or Multiple Operation
|
ユーザー |
![]() |
提出日時 | 2019-10-25 22:58:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 657 bytes |
コンパイル時間 | 519 ms |
コンパイル使用メモリ | 67,448 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-07 03:37:19 |
合計ジャッジ時間 | 1,112 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 2 |
ソースコード
#include <iostream> #include <vector> using namespace std; typedef long long ll; ll solve(int a, int b, int c) { if (c == 1) { return (ll)a*(ll)b; } // cerr << a << " " << b << " " << c << endl; ll ret = 0; int tmp = a; while (tmp > 0) { // cerr << tmp << " "; if (tmp < 2*c-1) { tmp -= c-1; } else if (tmp % c == 0) { tmp /= c; } else { tmp -= tmp%c; } ret += 1; } // cerr << endl; // cerr << ret << endl; return ret*(ll)b; } int main() { int q; cin >> q; for (int i = 0; i < q; ++i) { int a, b, c; cin >> a >> b >> c; ll ans = solve(a, b, c); cout << ans << endl; } }