結果

問題 No.36 素数が嫌い!
ユーザー bluemeganebluemegane
提出日時 2020-09-07 13:46:52
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,169 bytes
コンパイル時間 1,313 ms
コンパイル使用メモリ 63,936 KB
実行使用メモリ 65,432 KB
最終ジャッジ日時 2023-08-19 16:41:18
合計ジャッジ時間 38,103 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2,205 ms
56,616 KB
testcase_02 AC 52 ms
20,744 KB
testcase_03 AC 55 ms
23,488 KB
testcase_04 AC 51 ms
20,732 KB
testcase_05 AC 57 ms
21,528 KB
testcase_06 AC 58 ms
21,704 KB
testcase_07 AC 58 ms
23,480 KB
testcase_08 AC 56 ms
23,592 KB
testcase_09 AC 58 ms
23,604 KB
testcase_10 WA -
testcase_11 AC 746 ms
34,184 KB
testcase_12 AC 3,029 ms
63,624 KB
testcase_13 AC 3,022 ms
65,368 KB
testcase_14 AC 1,643 ms
50,300 KB
testcase_15 AC 58 ms
19,552 KB
testcase_16 AC 53 ms
20,784 KB
testcase_17 AC 52 ms
20,704 KB
testcase_18 AC 56 ms
21,564 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1,325 ms
46,472 KB
testcase_25 WA -
testcase_26 AC 1,604 ms
47,696 KB
testcase_27 AC 2,492 ms
59,776 KB
testcase_28 AC 1,559 ms
49,176 KB
testcase_29 AC 2,902 ms
62,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Linq;
using System.Collections.Generic;
using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        if (n <= 5) { Console.WriteLine("NO"); goto exit; }
        var a = GeneratePrime((int)Sqrt(n));
        getAns(n, a);
    exit:;
    }
    static void getAns(long n, List<int> a)
    {
        var count = 0;
        foreach (var x in a)
        {
            while (true)
            {
                if (n % x == 0)
                {
                    count++;
                    if (count >= 3) { Console.WriteLine("YES"); return; }
                    n /= x;
                }
                else break;
            }
        }
        Console.WriteLine("NO");
    }
    static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Math.Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
}
0