結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2016-11-01 04:51:53 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 77 ms / 5,000 ms |
| コード長 | 1,383 bytes |
| コンパイル時間 | 2,039 ms |
| コンパイル使用メモリ | 105,216 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-10-01 15:49:49 |
| 合計ジャッジ時間 | 4,020 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
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);
}
}
}
}
mban