結果

問題 No.36 素数が嫌い!
ユーザー snrnsidysnrnsidy
提出日時 2021-09-08 00:42:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 1,856 ms
コンパイル使用メモリ 199,356 KB
実行使用メモリ 13,388 KB
最終ジャッジ日時 2023-08-25 19:23:38
合計ジャッジ時間 6,817 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
13,228 KB
testcase_01 WA -
testcase_02 AC 93 ms
13,108 KB
testcase_03 AC 92 ms
13,136 KB
testcase_04 AC 92 ms
13,084 KB
testcase_05 AC 93 ms
13,288 KB
testcase_06 AC 93 ms
13,088 KB
testcase_07 AC 93 ms
13,100 KB
testcase_08 AC 92 ms
13,100 KB
testcase_09 AC 92 ms
13,124 KB
testcase_10 AC 91 ms
13,284 KB
testcase_11 AC 126 ms
13,260 KB
testcase_12 AC 198 ms
13,080 KB
testcase_13 AC 200 ms
13,108 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 93 ms
13,192 KB
testcase_17 AC 93 ms
13,084 KB
testcase_18 AC 94 ms
13,100 KB
testcase_19 AC 95 ms
13,260 KB
testcase_20 AC 104 ms
13,284 KB
testcase_21 AC 92 ms
13,180 KB
testcase_22 AC 93 ms
13,260 KB
testcase_23 AC 93 ms
13,092 KB
testcase_24 WA -
testcase_25 AC 94 ms
13,132 KB
testcase_26 AC 159 ms
13,164 KB
testcase_27 AC 184 ms
13,104 KB
testcase_28 AC 157 ms
13,104 KB
testcase_29 AC 196 ms
13,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

bool isprime[10000005];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long int N;

	cin >> N;

	memset(isprime,true,sizeof(isprime));

	for(int i=2;i<=10000000;i++)
	{
		if(isprime[i])
		{
			for(int j=2*i;j<=10000000;j+=i)
			{
				isprime[j] = false;
			}
		}
	}
	if(N==1)
	{
		cout << "NO" << '\n';
	}
	else
	{
		for(int i=2;i<=sqrt(N);i++)
		{
			if(N%i==0 && isprime[i]==false)
			{
				cout << "YES" << '\n';
				return 0;
			}
		}

		cout << "NO" << '\n';
	}

	return 0;
}
0