| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 149643 | 肖之睿 | 判断质数(使用while循环) | C++ | Accepted | 1 MS | 280 KB | 416 | 2026-03-15 14:44:57 |
#include<bits/stdc++.h> #define ll long long using namespace std; int main(){ int a; int b; cin>>a; //比2小的数,不是质数 if(a<2){ cout<<"NO"; return 0; } //在2~n-1范围内找第三个数 for(int b=2;b<=a-1;b++){ //一旦找到,说明存在第三个因数,不是质数 if(a%b==0){ cout<<"No"; return 0; } } cout<<"Yes"; return 0; }