Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
97676 | 王思颜 | 判断素数II | C++ | Accepted | 15 MS | 272 KB | 326 | 2024-11-16 12:11:20 |
#include<bits/stdc++.h> using namespace std; int he(int b){ if (b < 2){ return 0; } for (int i = 2;i < b;i++){ if (b % i == 0){ return 0; } } return 1; } int main(){ int n,a,m = 0; cin>>n; for (int j = 2;j <= n;j++){ a = he(j); if (a == 1){ m++; } } cout<<m; return 0; }