結果

問題 No.7 プライムナンバーゲーム
ユーザー akichiakichi
提出日時 2017-08-18 22:46:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 703 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 110,452 KB
実行使用メモリ 25,968 KB
最終ジャッジ日時 2024-04-09 04:22:45
合計ジャッジ時間 2,146 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,592 KB
testcase_01 AC 24 ms
25,888 KB
testcase_02 AC 53 ms
23,844 KB
testcase_03 AC 27 ms
25,460 KB
testcase_04 AC 24 ms
21,688 KB
testcase_05 AC 24 ms
23,848 KB
testcase_06 AC 32 ms
23,464 KB
testcase_07 AC 29 ms
23,848 KB
testcase_08 AC 27 ms
25,968 KB
testcase_09 AC 37 ms
25,712 KB
testcase_10 AC 24 ms
23,596 KB
testcase_11 AC 29 ms
23,856 KB
testcase_12 AC 45 ms
23,724 KB
testcase_13 AC 47 ms
25,624 KB
testcase_14 AC 54 ms
25,732 KB
testcase_15 AC 52 ms
23,572 KB
testcase_16 AC 51 ms
21,684 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
class Program {
    static void Main() {
        int n = int.Parse(Console.ReadLine());

        List<int> ps = new List<int> { 2 };
        for (int i = 3; i < n; i++) {
            for (int j = 2; j < i; j++) {
                if (i % j == 0) goto exit;
            }
            ps.Add(i);
            exit:;
        }

        bool[] win = new bool[n + 1];

        for (int i = 2; i < n - 1; i++) {
            if (win[i]) continue;
            foreach (int p in ps) {
                int t = i + p;
                if (n < t) break;
                win[t] = true;
            }
        }

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