結果

問題 No.915 Plus Or Multiple Operation
ユーザー BwambocosBwambocos
提出日時 2019-10-25 21:59:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 196,012 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 18:39:36
合計ジャッジ時間 3,035 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL Q;
	in >> Q;
	std::vector<LL>A(Q), B(Q), C(Q);
	rep(i, Q) in >> A[i] >> B[i] >> C[i];

	rep(i, Q)
	{
		if (C[i] == 1)
		{
			out << -1 << std::endl;
			continue;
		}

		LL ans = 0, t = A[i];
		while (t > 0)
		{
			if (t % C[i] == 0)
			{
				t /= C[i];
				++ans;
			}
			else
			{
				if (t < C[i] * 2)
				{
					ans += (t + C[i] - 1) / C[i];
					t = 0;
					break;
				}
				else
				{
					t -= t % C[i];
					++ans;
				}
			}
		}

		out << ans * B[i] << std::endl;
	}
}
0