結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2014-11-01 18:10:54 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,363 bytes |
コンパイル時間 | 2,974 ms |
コンパイル使用メモリ | 112,900 KB |
実行使用メモリ | 25,944 KB |
最終ジャッジ日時 | 2024-12-30 16:03:04 |
合計ジャッジ時間 | 4,358 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 4 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; class Program { public static void Main(string[] args) { long n = long.Parse(Console.ReadLine()); long upper = (long)Math.Min(Math.Sqrt(n) + 1, n - 1); bool[] used = new bool[upper]; bool[] prime = new bool[upper]; if (upper >= 3) { used[2] = true; prime[2] = true; } if (upper >= 4) { used[3] = true; prime[3] = true; } for (long i = 2; i <= Math.Sqrt(n); i++) { if (n % i == 0) { if (!used[i]) { used[i] = true; long d = (long)Math.Min(Math.Sqrt(n) + 1, n - 1); bool isPrime = true; for (long k = 2; k <= d; k++) { if (i%k == 0) { isPrime = false; break; } } prime[i] = isPrime; } if (!prime[i]) { Console.WriteLine("YES"); return; } } } Console.WriteLine("NO"); } }