結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | yuki2006 |
提出日時 | 2022-06-14 01:43:11 |
言語 | C# (.NET 8.0.203) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,826 bytes |
コンパイル時間 | 7,903 ms |
コンパイル使用メモリ | 166,656 KB |
実行使用メモリ | 185,088 KB |
最終ジャッジ日時 | 2024-04-09 05:08:34 |
合計ジャッジ時間 | 9,838 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
29,568 KB |
testcase_01 | AC | 50 ms
29,568 KB |
testcase_02 | AC | 63 ms
30,464 KB |
testcase_03 | AC | 51 ms
29,568 KB |
testcase_04 | AC | 51 ms
29,440 KB |
testcase_05 | AC | 51 ms
29,052 KB |
testcase_06 | AC | 63 ms
30,592 KB |
testcase_07 | AC | 62 ms
30,584 KB |
testcase_08 | AC | 51 ms
29,568 KB |
testcase_09 | AC | 62 ms
30,556 KB |
testcase_10 | WA | - |
testcase_11 | AC | 62 ms
30,848 KB |
testcase_12 | AC | 63 ms
30,464 KB |
testcase_13 | AC | 64 ms
30,336 KB |
testcase_14 | AC | 63 ms
30,848 KB |
testcase_15 | AC | 63 ms
30,588 KB |
testcase_16 | AC | 65 ms
185,088 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (98 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); } }