結果

問題 No.1330 Multiply or Divide
コンテスト
ユーザー さかぽん
提出日時 2021-01-08 21:35:40
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 111,500 KB
実行使用メモリ 45,896 KB
最終ジャッジ日時 2024-11-16 10:31:19
合計ジャッジ時間 7,634 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 38 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
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();

		a = a.Where(x => Gcd(x, p) == 1).ToArray();
		if (!a.Any()) { Console.WriteLine(-1); return; }
		var amax = a.Max();

		long x = 1;
		for (int i = 1; ; i++)
		{
			x *= amax;
			if (x > m)
			{
				Console.WriteLine(i);
				return;
			}
		}
	}

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