| 提出番号 | 583 |
|---|---|
| 提出者 | ecasdqina |
| 言語 | C++ |
| 提出日時 | 2017-07-25 23:54:18 |
| 問題名 | (21)素数列挙 |
| 結果 | AC |
| 点数 | 100% |
| テストケース | 結果 | 得点 | 実行時間 | メモリ使用量 |
|---|---|---|---|---|
| 1 | AC | 100% | 2ms | 8192KB |
| 2 | AC | 100% | 2ms | 7696KB |
| 3 | AC | 100% | 24ms | 8000KB |
| 4 | AC | 100% | 122ms | 7520KB |
| 5 | AC | 100% | 1ms | 7712KB |
#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))+1;j++){
if(i%j==0) f=false;
}
if(f) cout << i << " ";
}
return 0;
}