結果

問題 No.36 素数が嫌い!
ユーザー nanophoto12nanophoto12
提出日時 2014-11-01 18:10:54
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,363 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 103,192 KB
実行使用メモリ 24,900 KB
最終ジャッジ日時 2023-08-29 00:09:43
合計ジャッジ時間 5,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
22,740 KB
testcase_01 AC 54 ms
22,772 KB
testcase_02 AC 54 ms
20,804 KB
testcase_03 AC 54 ms
20,792 KB
testcase_04 AC 54 ms
20,728 KB
testcase_05 AC 55 ms
20,856 KB
testcase_06 WA -
testcase_07 AC 54 ms
20,736 KB
testcase_08 AC 54 ms
20,736 KB
testcase_09 AC 54 ms
22,828 KB
testcase_10 AC 55 ms
22,696 KB
testcase_11 AC 96 ms
20,732 KB
testcase_12 AC 182 ms
20,736 KB
testcase_13 WA -
testcase_14 AC 56 ms
20,916 KB
testcase_15 AC 54 ms
20,732 KB
testcase_16 AC 55 ms
20,816 KB
testcase_17 AC 55 ms
20,840 KB
testcase_18 AC 54 ms
20,812 KB
testcase_19 AC 54 ms
22,772 KB
testcase_20 AC 62 ms
20,664 KB
testcase_21 AC 54 ms
20,840 KB
testcase_22 AC 54 ms
20,728 KB
testcase_23 AC 54 ms
22,868 KB
testcase_24 AC 54 ms
20,836 KB
testcase_25 AC 54 ms
22,776 KB
testcase_26 AC 132 ms
20,828 KB
testcase_27 WA -
testcase_28 AC 130 ms
20,856 KB
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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");        
    }
}
0