結果

問題 No.1330 Multiply or Divide
ユーザー さかぽんさかぽん
提出日時 2021-01-08 22:12:06
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,132 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 107,008 KB
実行使用メモリ 43,776 KB
最終ジャッジ日時 2024-04-28 03:25:46
合計ジャッジ時間 6,681 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
18,816 KB
testcase_01 AC 101 ms
37,632 KB
testcase_02 AC 24 ms
18,816 KB
testcase_03 AC 23 ms
18,688 KB
testcase_04 AC 25 ms
18,560 KB
testcase_05 AC 24 ms
18,688 KB
testcase_06 AC 83 ms
33,024 KB
testcase_07 WA -
testcase_08 AC 116 ms
39,168 KB
testcase_09 AC 123 ms
39,552 KB
testcase_10 AC 116 ms
38,912 KB
testcase_11 AC 115 ms
39,296 KB
testcase_12 AC 115 ms
39,296 KB
testcase_13 AC 24 ms
18,688 KB
testcase_14 AC 23 ms
18,688 KB
testcase_15 AC 25 ms
18,560 KB
testcase_16 AC 24 ms
18,560 KB
testcase_17 AC 24 ms
18,688 KB
testcase_18 AC 110 ms
39,424 KB
testcase_19 AC 112 ms
39,424 KB
testcase_20 AC 117 ms
39,168 KB
testcase_21 AC 113 ms
39,552 KB
testcase_22 AC 113 ms
39,424 KB
testcase_23 AC 129 ms
43,776 KB
testcase_24 AC 25 ms
18,560 KB
testcase_25 AC 25 ms
18,304 KB
testcase_26 AC 25 ms
18,816 KB
testcase_27 AC 24 ms
18,816 KB
testcase_28 AC 25 ms
18,816 KB
testcase_29 AC 23 ms
18,432 KB
testcase_30 AC 24 ms
18,688 KB
testcase_31 AC 24 ms
18,688 KB
testcase_32 AC 24 ms
18,816 KB
testcase_33 AC 22 ms
18,560 KB
testcase_34 AC 92 ms
36,480 KB
testcase_35 AC 44 ms
23,552 KB
testcase_36 AC 85 ms
35,456 KB
testcase_37 AC 79 ms
34,304 KB
testcase_38 AC 56 ms
26,112 KB
testcase_39 AC 50 ms
24,056 KB
testcase_40 AC 52 ms
24,704 KB
testcase_41 AC 39 ms
21,760 KB
testcase_42 AC 77 ms
33,792 KB
testcase_43 AC 83 ms
34,944 KB
testcase_44 AC 83 ms
33,024 KB
testcase_45 AC 92 ms
33,024 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++)
			{
				dp[i + j + 1] = Math.Max(dp[i + j + 1], x * da[j]);
			}
		}
		Console.WriteLine(-1);
	}

	static long Gcd(long a, long b) { for (long r; (r = a % b) > 0; a = b, b = r) ; return b; }
}
0