結果

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