結果

問題 No.1330 Multiply or Divide
ユーザー さかぽんさかぽん
提出日時 2021-01-08 22:17:59
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,068 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 111,680 KB
実行使用メモリ 44,160 KB
最終ジャッジ日時 2024-04-28 03:33:54
合計ジャッジ時間 4,984 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
18,816 KB
testcase_01 AC 92 ms
37,248 KB
testcase_02 AC 21 ms
18,560 KB
testcase_03 AC 20 ms
18,688 KB
testcase_04 AC 20 ms
18,816 KB
testcase_05 AC 20 ms
18,688 KB
testcase_06 AC 79 ms
32,896 KB
testcase_07 WA -
testcase_08 AC 108 ms
39,552 KB
testcase_09 AC 118 ms
38,912 KB
testcase_10 AC 111 ms
38,912 KB
testcase_11 AC 107 ms
39,296 KB
testcase_12 AC 107 ms
39,552 KB
testcase_13 AC 22 ms
18,688 KB
testcase_14 AC 21 ms
18,432 KB
testcase_15 AC 20 ms
18,560 KB
testcase_16 AC 21 ms
18,688 KB
testcase_17 AC 21 ms
18,816 KB
testcase_18 AC 107 ms
39,424 KB
testcase_19 AC 108 ms
39,168 KB
testcase_20 AC 108 ms
39,296 KB
testcase_21 AC 104 ms
39,552 KB
testcase_22 AC 105 ms
39,424 KB
testcase_23 AC 117 ms
44,160 KB
testcase_24 AC 21 ms
18,432 KB
testcase_25 AC 20 ms
18,688 KB
testcase_26 AC 21 ms
18,560 KB
testcase_27 AC 21 ms
18,560 KB
testcase_28 AC 20 ms
18,688 KB
testcase_29 AC 20 ms
18,432 KB
testcase_30 AC 20 ms
18,688 KB
testcase_31 AC 20 ms
18,432 KB
testcase_32 AC 21 ms
18,816 KB
testcase_33 AC 20 ms
18,560 KB
testcase_34 AC 88 ms
36,352 KB
testcase_35 AC 41 ms
23,424 KB
testcase_36 AC 80 ms
35,328 KB
testcase_37 AC 75 ms
34,432 KB
testcase_38 AC 53 ms
25,856 KB
testcase_39 AC 44 ms
24,052 KB
testcase_40 AC 47 ms
24,320 KB
testcase_41 AC 37 ms
21,504 KB
testcase_42 AC 71 ms
33,664 KB
testcase_43 AC 80 ms
34,944 KB
testcase_44 AC 79 ms
32,768 KB
testcase_45 AC 76 ms
32,768 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[100];
		dp[0] = 1;

		for (int i = 0; i < dp.Length - da.Length; 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