| Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|
| 38988 | C++|刘一阳 | 埃氏筛法求区间质数 | C++ | Accepted | 0 MS | 240 KB | 442 | 2024-01-29 15:38:46 |
#include<iostream> #include<cmath> using namespace std; void printPrimes(int n) { for (int i=2;i<=n;i++) { bool isPrime=true; for (int j=2;j<=sqrt(i);j++) { if (i%j==0) { isPrime=false; break; } } if (isPrime){ cout<<i<<" "; } } } int main() { int n; cin >> n; printPrimes(n); return 0; }