結果

提出番号 582
提出者 ecasdqina
言語 C++
提出日時 2017-07-25 23:53:40
問題名 (21)素数列挙
結果 WA
点数 0%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 WA 0% 2ms 7968KB
2 WA 0% 2ms 7696KB
3 WA 0% 24ms 8320KB
4 WA 0% 124ms 7696KB
5 AC 100% 2ms 7696KB

ソースコード

#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

int n;
bool f=true;

int main(){
	cin >> n;
	if(n>2) cout << 2 << " ";
	else return 0;
	for(int i=3;i<n+1;i++){
		f=true;
		for(int j=2;j<floor(sqrt(i));j++){
			if(i%j==0) f=false;
		}
		if(f) cout << i << " ";
	}
	return 0;
}