結果

問題 No.7 プライムナンバーゲーム
ユーザー PoronPaPoronPa
提出日時 2019-05-27 20:24:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,978 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 112,628 KB
実行使用メモリ 52,264 KB
最終ジャッジ日時 2023-10-17 18:17:29
合計ジャッジ時間 27,675 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

namespace Program
{
    class Program
    {
        static void Main()
        {
            int count = int.Parse(Console.ReadLine());

            Program2 program2=new Program2();
            program2.Calc();

            Console.WriteLine(Convert.ToString(program2.GetWin(count)));
        }

    }

    class Program2
    {
        
        private int[] _win=new int[10001];
        private Sosuu sosuu = new Sosuu();

        public bool GetWin(int inNumber)
        {
            return _win[inNumber]==1;
        }
        public void Calc()
        {
            _win = _win.Select(x => -1).ToArray();
            _win[0] = 0;
            _win[1] = 0;
            for (int number = 2; number <= 10000; number++)
            {
                _win[number] = Convert.ToInt32(getWin(number));
            }
        }

        private bool getWin(int inNumber)
        {
            if (_win[inNumber] != -1)
                return _win[inNumber] == 1;

            List<int> card = sosuu.sosuuList.Where(x => x < inNumber && inNumber - x > 1).ToList();
            foreach (int item in card)
            {
                int Aite_No = inNumber - item;
                if (getWin(Aite_No))
                    return true;
            }

            return false;

        }

    }

    class Sosuu
    {
        public List<int> sosuuList = new List<int>();

        public Sosuu() {
            sosuuList.Add(2);

            for (int number = 3;number <= 10000;number++)
            {
                if (number % 2 != 0)
                {
                    for (int waruNumbre = 3; waruNumbre < number; waruNumbre++)
                    {
                        if (number % waruNumbre == 0)
                        {
                            continue;
                        }
                    }
                    sosuuList.Add(number);
                }
            }
        }
    }
}
0