結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | mban |
提出日時 | 2016-11-01 04:51:53 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 90 ms / 5,000 ms |
コード長 | 1,383 bytes |
コンパイル時間 | 1,923 ms |
コンパイル使用メモリ | 113,920 KB |
実行使用メモリ | 25,880 KB |
最終ジャッジ日時 | 2024-04-09 04:04:01 |
合計ジャッジ時間 | 4,477 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 90 ms
23,984 KB |
testcase_01 | AC | 90 ms
23,700 KB |
testcase_02 | AC | 90 ms
21,556 KB |
testcase_03 | AC | 89 ms
24,088 KB |
testcase_04 | AC | 90 ms
23,712 KB |
testcase_05 | AC | 89 ms
23,832 KB |
testcase_06 | AC | 89 ms
23,568 KB |
testcase_07 | AC | 90 ms
23,708 KB |
testcase_08 | AC | 89 ms
23,836 KB |
testcase_09 | AC | 89 ms
21,552 KB |
testcase_10 | AC | 90 ms
23,576 KB |
testcase_11 | AC | 90 ms
23,576 KB |
testcase_12 | AC | 90 ms
23,580 KB |
testcase_13 | AC | 89 ms
23,732 KB |
testcase_14 | AC | 89 ms
23,444 KB |
testcase_15 | AC | 89 ms
25,880 KB |
testcase_16 | AC | 89 ms
23,708 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; 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); } } } }