結果

問題 No.915 Plus Or Multiple Operation
ユーザー square1001square1001
提出日時 2020-09-03 16:07:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 521 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 73,376 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 19:00:11
合計ジャッジ時間 1,807 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	int Q;
	cin >> Q;
	while (Q--) {
		int A, B, C;
		cin >> A >> B >> C;
		int ops = inf;
		vector<int> seq = { A };
		do {
			int x = seq.back();
			seq.back() %= C;
			seq.push_back(x / C);
			int cost = int(seq.size()) - 1;
			for (int i : seq) {
				cost += (i + C - 2) / (C - 1);
			}
			ops = min(ops, cost);
		} while (C != 1 && seq.back() >= C);
		cout << 1LL * ops * B << endl;
	}
	return 0;
}
0