結果

問題 No.7 プライムナンバーゲーム
ユーザー mbanmban
提出日時 2016-11-01 04:51:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 1,383 bytes
コンパイル時間 2,398 ms
コンパイル使用メモリ 103,084 KB
実行使用メモリ 22,808 KB
最終ジャッジ日時 2023-07-24 20:40:36
合計ジャッジ時間 5,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
20,788 KB
testcase_01 AC 137 ms
22,808 KB
testcase_02 AC 136 ms
18,764 KB
testcase_03 AC 137 ms
20,772 KB
testcase_04 AC 137 ms
22,732 KB
testcase_05 AC 136 ms
18,588 KB
testcase_06 AC 136 ms
20,676 KB
testcase_07 AC 137 ms
20,712 KB
testcase_08 AC 136 ms
20,680 KB
testcase_09 AC 137 ms
22,740 KB
testcase_10 AC 138 ms
20,724 KB
testcase_11 AC 137 ms
20,736 KB
testcase_12 AC 136 ms
20,632 KB
testcase_13 AC 136 ms
20,696 KB
testcase_14 AC 137 ms
20,616 KB
testcase_15 AC 136 ms
20,764 KB
testcase_16 AC 137 ms
20,676 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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Magatro
{
    static int N;
    static bool[] ans = new bool[10001];
    static List<int> Primes = new List<int>();
    static void Main()
    {
        N = int.Parse(Console.ReadLine());
        ans[0] = true;
        ans[1] = true;
        PrimeCnt();
        for(int i = 0; i <= 10000; i++)
        {
            for(int j = 0; j<Primes.Count; j++)
            {
                if (i + Primes[j] <= 10000)
                {
                    ans[i + Primes[j]] |= !ans[i];
                }
                else
                {
                    break;
                }
            }
        }
        if (ans[N])
        {
            Console.WriteLine("Win");
        }
        else
        {
            Console.WriteLine("Lose");
        }
    }
    static void PrimeCnt()
    {
        bool[] A = new bool[10001];
        A[0] = true;
        A[1] = true;
        for (int i = 2; i < 100; i++)
        {
            if (!A[i])
            {
                for (int j = i + i; j<= 10000; j += i)
                {
                    A[j] = true;
                }
            }
        }
        for (int i = 0; i <= 10000; i++)
        {
            if (!A[i])
            {
                Primes.Add(i);
            }
        }
    }


}


0