結果

問題 No.8023 素数判定するだけ
ユーザー ok
提出日時 2019-09-04 16:21:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 1,334 bytes
コンパイル時間 1,081 ms
コンパイル使用メモリ 69,888 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 17:35:30
合計ジャッジ時間 6,243 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main(){
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

int add(int a, int b, bool one = false){
	
	if(one){
		if(a==true){
			if(b==true) return (true<<true)|true;
			if(b==false) return (true<<true);
		}
		if(a==false){
			if(b==true) return (true<<true);
			if(b==false) return true;
		}
		if(a&true){
			if(b&true){
				return (add(a>>true,b>>true,true)<<true)|true;
			} else {
				return (add(a>>true,b>>true,true)<<true);
			}			
		} else {
			if(b&true){
				return (add(a>>true,b>>true,true)<<true);
			} else {
				return (add(a>>true,b>>true,false)<<true)|true;
			}	
		}
	} else {
		if(a==true){
			if(b==true) return (true<<true);
			if(b==false) return true;
		}
		if(a==false){
			if(b==true) return true;
			if(b==false) return false;
		}
		if(a&true){
			if(b&true){
				return add(a>>true,b>>true,true)<<true;
			} else {
				return (add(a>>true,b>>true,false)<<true)|true;
			}			
		} else {
			if(b&true){
				return (add(a>>true,b>>true,false)<<true)|true;
			} else {
				return add(a>>true,b>>true,false)<<true;
			}	
		}
	}
	
}

main(){
	int N;
	vector<int> PN;
	
	cin>>N;
	
	PN.resize(add(N,true));
	
	PN[true] = true;
	for(int i = true<<true; i <= N; i = add(i,true)){
		if(PN[i] == false){
			for(int j = add(i,i); j <= N; j = add(j,i)){
				PN[j] = true;
			}
		}
	}
	
	cout<<(PN[N]?"NO":"YES")<<endl;
}
0