結果

問題 No.36 素数が嫌い!
ユーザー 184
提出日時 2014-10-08 00:53:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 552 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 65,492 KB
実行使用メモリ 42,368 KB
最終ジャッジ日時 2024-12-30 07:54:37
合計ジャッジ時間 8,876 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other AC * 3 RE * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         long long n;scanf("%lld",&n);
      |                     ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

using namespace std;

/*
184 //名前が 184

no36
*/ 

	int p[10000001]={0,0,1,1,0,1};
int main(){
	long long n;scanf("%lld",&n);
	if(n==2){
		printf("NO\n");return 0;
	}
	for(int i=3;i*i<=n;i+=2)p[i]=1;
	for(int i=3;i*i<=n;i+=2)if(p[i])for(int j=i+i;j<=n;j+=i)p[j]=0;
	for(int i=3;i*i<=n;i+=2){
		if(n%p[i]==0&&n!=i){ 
			printf("YES\n");return 0;
		}
	}
	printf("NO\n");
	return 0;
} 
0