結果

問題 No.7 プライムナンバーゲーム
ユーザー しらゆきしらゆき
提出日時 2015-11-24 21:34:48
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 993 ms / 5,000 ms
コード長 784 bytes
コンパイル時間 896 ms
コンパイル使用メモリ 108,244 KB
実行使用メモリ 25,940 KB
最終ジャッジ日時 2024-04-09 03:52:22
合計ジャッジ時間 8,172 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
25,616 KB
testcase_01 AC 23 ms
25,620 KB
testcase_02 AC 993 ms
25,940 KB
testcase_03 AC 54 ms
23,576 KB
testcase_04 AC 28 ms
25,800 KB
testcase_05 AC 28 ms
23,828 KB
testcase_06 AC 240 ms
25,804 KB
testcase_07 AC 154 ms
23,856 KB
testcase_08 AC 73 ms
23,500 KB
testcase_09 AC 382 ms
21,560 KB
testcase_10 AC 22 ms
25,680 KB
testcase_11 AC 156 ms
23,860 KB
testcase_12 AC 667 ms
23,632 KB
testcase_13 AC 719 ms
23,576 KB
testcase_14 AC 992 ms
25,744 KB
testcase_15 AC 934 ms
23,900 KB
testcase_16 AC 840 ms
23,644 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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());

        var ans = new string[10001];
        ans[0] = ans[1] = "Win";

        for(int i = 2; i <= n; i++)
        {
            ans[i] = "Lose";
            for (int j = 2; j <= i; j++)
            {
                if (IsPrime(j) && ans[i - j] == "Lose")
                {
                    ans[i] = "Win";
                    break;
                }
            }
        }

        Console.WriteLine(ans[n]);
    }

    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