1 solutions
-
0
C++ :
#include <algorithm> #include <cstdio> using namespace std; const int N = 1e5 + 5; int n, p[N], cnt; bool np[N]; int main() { scanf("%d", &n); for (int i = 2; i <= n; i++) { if (!np[i]) p[++cnt] = i; for (int j = 1; j <= cnt && i * p[j] <= n; j++) { np[i * p[j]] = 1; if (i % p[j] == 0) break; } } printf("%d\n", 1 + cnt); return 0; }
- 1
Information
- ID
- 105
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By