Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
149645 卢语宸 判断质数(使用while循环) C++ Time Limit Exceeded 1000 MS 264 KB 421 2026-03-15 14:47:29

Tests(0/10):


Code:

#include<bits/stdc++.h> using namespace std; int main() { int a,b=2; cin>>a; //比2小的数,不是质数 if(a<b) { cout<<"No"; return 0; } //在2~n-1范围内第三个因数 while(b<=a-1) { //一但找到,说明存在第三个因数,不是质数 if(a%b==0) { cout<<"No"; b++; return 0; } } //不存在第三个因数,则为质数 cout<<"Yes"; return 0; }