結果

問題 No.7 プライムナンバーゲーム
ユーザー しらゆきしらゆき
提出日時 2015-11-24 21:17:56
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 699 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 104,356 KB
実行使用メモリ 22,720 KB
最終ジャッジ日時 2023-10-11 18:27:27
合計ジャッジ時間 8,749 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
22,720 KB
testcase_01 AC 52 ms
20,660 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        if (Judge(n)) Console.WriteLine("Win");
        else Console.WriteLine("Lose");
    }

    static bool Judge(int a)
    {
        bool b = false;
        if (a == 0 || a == 1) b = true;
        for(int i=2;i<= a; i++)
        {
            if (IsPrime(i) && Judge(a - i) == false) b = true;
        }
        return b;
    }

    static bool IsPrime(int a)
    {
        bool b = true;
        for (int i=2;i*i<= a; i++)
        {
            if (a % i == 0)
            {
                b = false;
                break;
            }           
        }
        return b;
    }
}
0