結果

問題 No.7 プライムナンバーゲーム
ユーザー akichi
提出日時 2017-08-18 22:46:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 703 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 104,320 KB
実行使用メモリ 17,792 KB
最終ジャッジ日時 2024-10-01 16:06:40
合計ジャッジ時間 2,072 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
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