結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-08 22:13:57 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,086 bytes |
| コンパイル時間 | 1,205 ms |
| コンパイル使用メモリ | 112,072 KB |
| 実行使用メモリ | 43,776 KB |
| 最終ジャッジ日時 | 2024-11-16 12:41:08 |
| 合計ジャッジ時間 | 6,295 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 44 WA * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}