题解(A21445.哥德巴赫猜想)
2024-09-07 12:35:17
发布于:四川
6阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
bool ss(int x){
if(x1){
return false;
}
for(int j=2;j<=x/j;j++){
if(x%j0){
return false;
}
}
return true;
}
void gd(int m){
for(x=1;x<=m;x++){
y=m-x;
if(ss(y)==true&&ss(x)true){
break;
}
}
}
int main(){
cin>>n;
for(int i=4;i<=n;i++){
if(i%20){
gd(i);
cout<<i<<'='<<x<<'+'<<y<<endl;
}else{
continue;
}
}
return 0;
}
这里空空如也
有帮助,赞一个