結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
|
提出日時 | 2021-01-15 08:59:31 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,345 bytes |
コンパイル時間 | 974 ms |
コンパイル使用メモリ | 113,992 KB |
実行使用メモリ | 48,096 KB |
最終ジャッジ日時 | 2024-11-25 06:26:33 |
合計ジャッジ時間 | 15,815 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 TLE * 2 |
コンパイルメッセージ
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 No._07 { class Program { static List<int> prime = new List<int>(); static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); primeCheck(n); if (judgmentCheck(n)) { Console.WriteLine("Win"); } else { Console.WriteLine("Lose"); } } static void primeCheck(int n) { bool[] data = Enumerable.Repeat(true, n + 1).ToArray(); for (int i = 4; i <= n; i += 2) data[i] = false; for (int i = 3; i <= (int)Math.Sqrt((double)n); i += 2) for (int j = 2; i * j <= n; j++) data[i * j] = false; for (int i = n; i >= 2; i--) if (data[i]) prime.Add(i); return; } static bool judgmentCheck(int n) { if (n > 1) { foreach (int a in prime) if (n >= a) if (!judgmentCheck(n - a)) return true; return false; } else return true; } } }