wenlebo @ 2022-07-14 14:14:12
#include <bits/stdc++.h>
using namespace std;
bool l[20004]{0};
int main(){
l[1]=1;
for(long long g=2;g<20004;g++){
if(l[g]==1){
continue;
}
for(int h=2;g*h<20004;h++){
l[g*h]=1;
}
}
int h;
cin>>h;
for(int z=2;z<114514;z++)
for(int zz=2;zz<20001;zz++){
if(l[z]==0&&l[zz]==0&&l[h-z-zz]==0&&(h-z-zz>=1)){
cout<<z<<" "<<zz<<" "<<h-z-zz;
return 0;
}
}
return 0;
}
in 999
out 3 5 991
by StarLbright40 @ 2022-07-14 14:27:06
@wenlebo if 里判断的顺序不对,如果 h-z-zz
为负,会在 l[h-z-zz]=0
这里越界
by wenlebo @ 2022-07-14 14:46:10
@StarLbright40 万分感谢,过了