結果

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

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 100% 1ms 8320KB
2 AC 100% 2ms 7520KB
3 AC 100% 1819ms 7520KB
4 TLE 0% 17477ms 7968KB
5 AC 100% 1ms 8304KB

ソースコード

#include <iostream>
#include <algorithm>
#include <cstdlib>
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<i;j++){
			if(i%j==0) f=false;
		}
		if(f) cout << i << " ";
	}
	return 0;
}