結果

問題 No.1330 Multiply or Divide
ユーザー さかぽんさかぽん
提出日時 2021-01-08 22:20:43
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 3,567 ms
コンパイル使用メモリ 105,848 KB
実行使用メモリ 49,000 KB
最終ジャッジ日時 2023-08-10 13:08:55
合計ジャッジ時間 10,493 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,564 KB
testcase_01 AC 148 ms
42,612 KB
testcase_02 AC 60 ms
21,588 KB
testcase_03 AC 60 ms
23,612 KB
testcase_04 AC 61 ms
21,628 KB
testcase_05 AC 59 ms
21,636 KB
testcase_06 AC 128 ms
36,072 KB
testcase_07 AC 217 ms
39,984 KB
testcase_08 AC 161 ms
44,396 KB
testcase_09 AC 164 ms
42,256 KB
testcase_10 AC 162 ms
42,384 KB
testcase_11 AC 158 ms
42,392 KB
testcase_12 AC 161 ms
46,400 KB
testcase_13 AC 59 ms
23,624 KB
testcase_14 AC 58 ms
21,528 KB
testcase_15 AC 58 ms
21,464 KB
testcase_16 AC 60 ms
23,624 KB
testcase_17 AC 59 ms
23,676 KB
testcase_18 AC 156 ms
42,216 KB
testcase_19 AC 156 ms
42,248 KB
testcase_20 AC 157 ms
42,348 KB
testcase_21 AC 158 ms
42,316 KB
testcase_22 AC 162 ms
42,300 KB
testcase_23 AC 177 ms
49,000 KB
testcase_24 AC 62 ms
21,500 KB
testcase_25 AC 59 ms
21,700 KB
testcase_26 AC 59 ms
21,648 KB
testcase_27 AC 60 ms
21,644 KB
testcase_28 AC 60 ms
21,640 KB
testcase_29 AC 60 ms
21,644 KB
testcase_30 AC 60 ms
23,676 KB
testcase_31 AC 61 ms
21,648 KB
testcase_32 AC 60 ms
23,620 KB
testcase_33 AC 59 ms
23,572 KB
testcase_34 AC 136 ms
41,492 KB
testcase_35 AC 86 ms
26,568 KB
testcase_36 AC 130 ms
40,404 KB
testcase_37 AC 124 ms
37,088 KB
testcase_38 AC 101 ms
30,392 KB
testcase_39 AC 90 ms
24,744 KB
testcase_40 AC 94 ms
27,144 KB
testcase_41 AC 80 ms
23,176 KB
testcase_42 AC 119 ms
38,660 KB
testcase_43 AC 128 ms
37,548 KB
testcase_44 AC 129 ms
34,168 KB
testcase_45 AC 131 ms
36,040 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

class B
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static (int, int, int) Read3() { var a = Read(); return (a[0], a[1], a[2]); }
	static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static void Main()
	{
		var (n, m, p) = Read3();
		var a = ReadL();

		var amax = a.Max();

		// p^j を含む a_i
		var pa = new long[32];
		// a_i / p^j
		var da = new long[32];

		foreach (var v in a)
		{
			var t = v;
			var j = 0;
			while (t % p == 0)
			{
				t /= p;
				j++;
			}
			pa[j] = Math.Max(pa[j], v);
			da[j] = Math.Max(da[j], t);
		}

		var dp = new long[200];
		dp[0] = 1;

		for (int i = 0; i < dp.Length - da.Length-20; i++)
		{
			var x = dp[i];
			if (x * amax > m)
			{
				Console.WriteLine(i + 1);
				return;
			}

			for (int j = 0; j < da.Length; j++)
			{
				if (da[j] == 0) continue;
				dp[i + j + 1] = Math.Max(dp[i + j + 1], x * da[j]);
			}
		}
		Console.WriteLine(-1);
	}
}
0