听取WA声一片
2024-04-14 13:21:47
发布于:江苏
63阅读
0回复
0点赞
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
cin>>n;
if(sqrt(n)==0){
cout<<"No";
}else{
cout<<"Yes";
}
}
为什么不对!
全部评论 3
sqrt是给一个数开平方。所有正整数开平方根都不为0。你需要去循环判断[2, sqrt(n)] (n!=2)中,是否有一个数是n的因子。
2024-04-14 来自
3#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
bool flag=true;
for(int i=2;i<n;i++){
if(n%i0){flag=false;break;}
}
if(flag1 and n!=1){cout<<"Yes";}
else{cout<<"No";}
return 0;
}//答案2025-11-18 来自 广东
0懂Macw07讲的吗
2025-07-18 来自 浙江
0

















有帮助,赞一个