結果

問題 No.726 Tree Game
ユーザー 👑 kakel-san
提出日時 2026-10-11 20:59:50
言語 C#
(.NET 10.0.403 + ACL)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 40 ms / 2,000 ms
+ 89µs
コード長 1,186 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,839 ms
コンパイル使用メモリ 171,948 KB
実行使用メモリ 32,936 KB
最終ジャッジ日時 2026-11-03 10:54:26
合計ジャッジ時間 10,800 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (194 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (x, y) = (c[0], c[1]);
        var xisprime = IsPrime(x);
        var yisprime = IsPrime(y);
        var nextx = x + 1;
        while (!IsPrime(nextx)) ++nextx;
        var nexty = y + 1;
        while (!IsPrime(nexty)) ++nexty;
        if (xisprime && yisprime)
        {
            WriteLine("Second");
            return;
        }
        if (x == 2 || y == 2)
        {
            WriteLine("Second");
            return;
        }
        var rest = nextx - x - 1 + nexty - y - 1;
        WriteLine(rest % 2 == 0 ? "Second" : "First");
    }
    static bool IsPrime(int a)
    {
        if (a < 2) return false;
        if (a < 4) return true;
        for (var i = 2; i * i <= a; ++i)
        {
            if (a % i == 0) return false;
        }
        return true;
    }
}
0