結果

問題 No.7 プライムナンバーゲーム
ユーザー pirorirori_n712pirorirori_n712
提出日時 2018-10-19 03:03:17
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 79 ms / 5,000 ms
コード長 955 bytes
コンパイル時間 2,660 ms
コンパイル使用メモリ 112,228 KB
実行使用メモリ 25,868 KB
最終ジャッジ日時 2024-04-09 04:33:26
合計ジャッジ時間 2,845 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,940 KB
testcase_01 AC 24 ms
23,676 KB
testcase_02 AC 79 ms
23,940 KB
testcase_03 AC 27 ms
23,856 KB
testcase_04 AC 24 ms
23,816 KB
testcase_05 AC 25 ms
24,112 KB
testcase_06 AC 40 ms
23,684 KB
testcase_07 AC 34 ms
25,868 KB
testcase_08 AC 28 ms
23,684 KB
testcase_09 AC 48 ms
25,836 KB
testcase_10 AC 24 ms
23,932 KB
testcase_11 AC 35 ms
25,700 KB
testcase_12 AC 63 ms
25,856 KB
testcase_13 AC 66 ms
23,424 KB
testcase_14 AC 79 ms
25,732 KB
testcase_15 AC 75 ms
23,680 KB
testcase_16 AC 71 ms
23,428 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.Linq;
using System.Collections.Generic;

class No7
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var list = new List<int>();
        var n = 0;
        for (int i = 2;  i < N-1; ++i)
        {
            var max = Math.Sqrt(i+1);
            n = i;
            for (int j = 2; j <= max; j++)
            {
                if (i % j == 0)
                {
                    n = 0;
                    break;
                }
            }
            if (n != 0) list.Add(n) ;
        }
        var winList = new bool[N+1];
        for (int i=4;i<=N;++i)
        {
            if (winList[i]) continue;
            for(int j = 0; j<list.Count; ++j)
            {
                var temp = i - list[j];
                if (temp < 2) break;
                if (!winList[temp]) winList[i] = true;
            }
        }
        Console.WriteLine(winList[N] ? "Win" : "Lose");
    }
}
0