Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
24144 | hetiantian | 【入门】筛选质数 | C++ | 通过 | 0 MS | 252 KB | 254 | 2023-07-21 14:40:16 |
#include <bits/stdc++.h> using namespace std; bool check(int x){ for(int i=2;i*i<=x;i++) if(x%i==0){ return false; } return true; } int main(){ int n; cin>>n; for(int i=2;i<=n;i++){ if(check(i)){ cout<<i<<endl; } } }