結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
|
提出日時 | 2022-06-14 01:43:11 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,826 bytes |
コンパイル時間 | 13,219 ms |
コンパイル使用メモリ | 169,564 KB |
実行使用メモリ | 185,948 KB |
最終ジャッジ日時 | 2024-10-01 16:47:37 |
合計ジャッジ時間 | 14,993 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 1 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (99 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main() { //a以下の素数の数==sosuの数//b==素数なのか調べたい数 int a = int.Parse(Console.ReadLine()), b = 3; List<int> sosu = new List<int>(); sosu.Add(2); while (b<=a)//素数の数を調べる { if (b % 2 == 0)//偶数は素数ではないのでスキップする { b++; continue; } else { bool sosu_yes = true; for(int i = 0; i < sosu.Count; i++)//登録されている素数の中で割り切れる数があるのかを調べる { if (b % sosu[i] == 0)//割り切れた場合素数ではないので処理を中断し、次に向かう { sosu_yes = false; break; } else if ((b < (sosu[i] * 2)) || (MathF.Sqrt(b) < sosu[i]))//bの1/2の数以下で割れなければ整数で割れないので中断する//また√bより大きい素数ではbは割り切れる事はないので中断する break; } if(sosu_yes)//持っている素数では割り切れなかった { sosu.Add(b);//お前も素数にならないか } } b++; } if (a % 3 == 0 && ((sosu[sosu.Count - 1] - sosu[sosu.Count - 2]) < 11)) Console.WriteLine("Lose"); else Console.WriteLine("Win"); //Console.WriteLine(sosu[sosu.Count - 1] - sosu[sosu.Count - 2]); //Console.WriteLine(sosu.Count); } }