結果

問題 No.36 素数が嫌い!
ユーザー suzusuzu
提出日時 2023-04-28 11:33:40
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 852 bytes
コンパイル時間 1,478 ms
コンパイル使用メモリ 110,864 KB
実行使用メモリ 816,172 KB
最終ジャッジ日時 2024-04-28 18:05:48
合計ジャッジ時間 8,535 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 22 ms
17,536 KB
testcase_03 AC 23 ms
17,536 KB
testcase_04 AC 23 ms
17,664 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;
namespace yukicoder
{
    class Program
    {
    	static void Main(string[] args)
    	{
    		long N = long.Parse(Console.ReadLine());
    		var sieve = new bool[N + 1];//falseは素数。trueは非素数。
    		sieve[0] = false;
    		sieve[1] = false;
    		
    		string ans = "NO";
			
    		for(long i = 2;i < (N / 2) + 1;i++)
    		{
    			if(!sieve[i])//素数の時実行。ふるいにかける。
    			{
    				for(long m = i + i;m < N + 1;m += i)
    				{
    					sieve[m] = true;
    				}
    			}
    			if(sieve[i] && i != 1 && i != N)//素数,1,使う数自身 以外かどうか
    			{
    				if(N % i == 0)
    				{
    					ans = "YES";
    					break;
    				}
    			}
    		}
    		Console.WriteLine(ans);
    		
    		
    		
    		
    	}
    }
}
0