| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 158228 | 林睿 | 判断素数 | C++ | Accepted | 1 MS | 272 KB | 662 | 2026-08-20 17:18:30 |
#include <iostream> #include <cmath> using namespace std; // 判断素数函数,是素数返回true,不是返回false bool isPrime(long long m) { if(m <= 1) return false; if(m == 2) return true; if(m % 2 == 0) //偶数直接排除 return false; // 只看奇数,i到sqrt(m) for(long long i = 3; i * i <= m; i += 2) { if(m % i == 0) return false; } return true; } int main() { long long m; cin >> m; if(isPrime(m)) { cout << "prime" << endl; } else { cout << "not prime" << endl; } return 0; }