結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | PoronPa |
提出日時 | 2019-05-30 22:58:33 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 272 ms / 5,000 ms |
コード長 | 2,105 bytes |
コンパイル時間 | 2,423 ms |
コンパイル使用メモリ | 114,676 KB |
実行使用メモリ | 52,956 KB |
最終ジャッジ日時 | 2024-04-09 04:39:07 |
合計ジャッジ時間 | 8,375 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 269 ms
52,456 KB |
testcase_01 | AC | 271 ms
52,456 KB |
testcase_02 | AC | 271 ms
52,832 KB |
testcase_03 | AC | 272 ms
50,788 KB |
testcase_04 | AC | 267 ms
50,792 KB |
testcase_05 | AC | 271 ms
52,852 KB |
testcase_06 | AC | 271 ms
50,784 KB |
testcase_07 | AC | 267 ms
52,708 KB |
testcase_08 | AC | 269 ms
50,936 KB |
testcase_09 | AC | 270 ms
50,796 KB |
testcase_10 | AC | 268 ms
50,672 KB |
testcase_11 | AC | 267 ms
50,660 KB |
testcase_12 | AC | 265 ms
52,576 KB |
testcase_13 | AC | 270 ms
50,800 KB |
testcase_14 | AC | 271 ms
50,664 KB |
testcase_15 | AC | 269 ms
50,796 KB |
testcase_16 | AC | 269 ms
52,956 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(program2.GetWin(count)); } } class Program2 { private int[] _win=new int[10001]; private Sosuu sosuu = new Sosuu(); public string GetWin(int inNumber) { return _win[inNumber]==1 ? "Win":"Lose"; } 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(GetWinCalc(number)); } } private bool GetWinCalc(int inNumber) { if (_win[inNumber] != -1) return _win[inNumber] == 1; List<int> card = sosuu.SosuuList.Where(x => x < inNumber && inNumber - x > 1).ToList(); if (card.Count == 0) return false; foreach (int item in card) { int aiteNo = inNumber - item; if (!GetWinCalc(aiteNo)) return true; } return false; } } class Sosuu { public List<int> SosuuList = new List<int>(); public Sosuu() { SosuuList.Add(2); SosuuList.Add(3); for (int number = 3;number <= 10000;number++) { if (number % 2 == 0) { continue; } for (int waruNumbre = 3; waruNumbre < number; waruNumbre++) { if (number % waruNumbre == 0) { break; } if(waruNumbre==number-1) SosuuList.Add(number); } } } } }