結果

問題 No.7 プライムナンバーゲーム
ユーザー skewesskewes
提出日時 2015-12-27 17:20:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 239 ms / 5,000 ms
コード長 715 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 106,260 KB
実行使用メモリ 25,940 KB
最終ジャッジ日時 2024-04-09 03:54:20
合計ジャッジ時間 3,403 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
25,560 KB
testcase_01 AC 21 ms
23,652 KB
testcase_02 AC 239 ms
23,860 KB
testcase_03 AC 34 ms
23,540 KB
testcase_04 AC 25 ms
23,520 KB
testcase_05 AC 25 ms
23,904 KB
testcase_06 AC 79 ms
23,392 KB
testcase_07 AC 59 ms
23,516 KB
testcase_08 AC 37 ms
25,784 KB
testcase_09 AC 111 ms
23,524 KB
testcase_10 AC 22 ms
23,640 KB
testcase_11 AC 58 ms
23,596 KB
testcase_12 AC 173 ms
23,524 KB
testcase_13 AC 184 ms
23,724 KB
testcase_14 AC 238 ms
25,940 KB
testcase_15 AC 227 ms
25,576 KB
testcase_16 AC 209 ms
23,648 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class _007
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            bool[] dp = new bool[n + 1];
            bool[] prime = new bool[n + 1];

            dp[0] = true;
            dp[1] = true;
            prime[2] = false;

            for (int i = 3; i < n + 1; i++)
            {
                for (int j = 2; j < i; j++)
                {
                    if (!prime[j])
                    {
                        prime[i] |= i % j == 0;

                        dp[i] |= !dp[i - j];
                    }
                }
            }

            Console.WriteLine(dp[n] ? "Win" : "Lose");
        }
    }
}
0