結果

問題 No.1352 Three Coins
コンテスト
ユーザー さかぽん
提出日時 2021-01-17 14:35:28
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 841 bytes
コンパイル時間 874 ms
コンパイル使用メモリ 106,112 KB
実行使用メモリ 40,064 KB
最終ジャッジ日時 2024-11-29 20:16:42
合計ジャッジ時間 33,997 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23 WA * 3 TLE * 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 C
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var a = Read();
		Array.Sort(a);

		//if (a.Any(x => x == 1)) return 0;
		if (Gcd(Gcd(a[0], a[1]), a[2]) > 1) return "INF";

		var u = new bool[a[0] * a[1]];
		for (int k = 0; k < 3; k++)
			for (int i = 0; i < u.Length; i += a[k])
				u[i] = true;

		for (int i = a[0]; i < u.Length; i++)
		{
			if (u[i]) continue;

			for (int j = 1; j < i; j++)
			{
				if (u[j] && u[i - j])
				{
					u[i] = true;
					break;
				}
			}
		}
		return u.Count(x => !x);
	}

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