結果

問題 No.1330 Multiply or Divide
ユーザー さかぽんさかぽん
提出日時 2021-01-08 22:13:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,086 bytes
コンパイル時間 2,805 ms
コンパイル使用メモリ 112,496 KB
実行使用メモリ 51,836 KB
最終ジャッジ日時 2024-04-28 03:28:07
合計ジャッジ時間 7,156 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
24,592 KB
testcase_01 AC 104 ms
45,528 KB
testcase_02 WA -
testcase_03 AC 23 ms
24,884 KB
testcase_04 AC 23 ms
24,880 KB
testcase_05 AC 24 ms
24,844 KB
testcase_06 AC 86 ms
41,136 KB
testcase_07 WA -
testcase_08 AC 119 ms
43,004 KB
testcase_09 AC 119 ms
45,440 KB
testcase_10 AC 116 ms
45,180 KB
testcase_11 AC 119 ms
45,456 KB
testcase_12 AC 117 ms
47,756 KB
testcase_13 AC 26 ms
24,624 KB
testcase_14 AC 24 ms
24,468 KB
testcase_15 AC 24 ms
26,768 KB
testcase_16 AC 25 ms
26,636 KB
testcase_17 AC 26 ms
24,620 KB
testcase_18 AC 114 ms
47,360 KB
testcase_19 AC 112 ms
47,484 KB
testcase_20 AC 112 ms
47,228 KB
testcase_21 AC 112 ms
47,232 KB
testcase_22 AC 110 ms
49,660 KB
testcase_23 AC 128 ms
51,836 KB
testcase_24 AC 24 ms
25,000 KB
testcase_25 AC 26 ms
26,532 KB
testcase_26 AC 23 ms
26,776 KB
testcase_27 AC 23 ms
24,620 KB
testcase_28 AC 25 ms
26,784 KB
testcase_29 AC 24 ms
24,620 KB
testcase_30 AC 24 ms
24,616 KB
testcase_31 AC 24 ms
26,916 KB
testcase_32 AC 25 ms
24,872 KB
testcase_33 AC 25 ms
24,748 KB
testcase_34 AC 91 ms
42,332 KB
testcase_35 AC 43 ms
28,076 KB
testcase_36 AC 84 ms
43,268 KB
testcase_37 AC 78 ms
42,584 KB
testcase_38 AC 57 ms
31,388 KB
testcase_39 AC 50 ms
28,004 KB
testcase_40 AC 51 ms
30,156 KB
testcase_41 AC 39 ms
28,120 KB
testcase_42 AC 77 ms
42,156 KB
testcase_43 AC 87 ms
40,920 KB
testcase_44 AC 86 ms
40,884 KB
testcase_45 AC 85 ms
36,912 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();

		if (m == 1) { Console.WriteLine(0); return; }
		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++)
			{
				dp[i + j + 1] = Math.Max(dp[i + j + 1], x * da[j]);
			}
		}
		Console.WriteLine(-1);
	}
}
0