czk15 @ 2017-07-27 16:22:39
下面是程序
#include<bits/stdc++.h>
using namespace std;
int ss(int n)
{
if(n==0||n==1) return 0;
for(int i=2;i<=sqrt(n);i++)
if(n%i==0) return 0;
return 1;
}
int main()
{
int n;
cin>>n;
for(int i=2;i<=n-4;i++)
if(ss(i))
for(int j=2;ss(j)&&j<=n-i;j++)
if(ss(n-i-j)){
cout<<i<<" "<<j<<" "<<n-i-j;
return 0;}
}
by czk15 @ 2017-07-27 16:22:57
求助
by wangdayu @ 2017-07-27 19:15:19
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
bool zhishu(int n){
if(n==1||n==0)return 0;
for(int i=2;i<=sqrt(n);i++)
if(n%i==0)return 0;
return 1;
}
int main(){
int n;cin>>n;
if(zhishu(n-4))cout<<"2 2 "<<n-4;else
{
for(int i=3;i<n;i+=2)
if(zhishu(i))
{
for(int j=3;j<n;i+=2)
if(zhishu(j))
{
if(zhishu(n-i-j))
{cout<<i<<" "<<j<<" "<<n-i-j;return 0;
}
}
}
}
}
我和你程序差不多 也是只有30
一脸懵逼
by wangdayu @ 2017-07-27 19:26:53
我过了
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
bool zhishu(int n){
if(n==1||n==0)return 0;
for(int i=2;i<=sqrt(n);i++)
if(n%i==0)return 0;
return 1;
}
int main(){
int n;cin>>n;
if(zhishu(n-4))cout<<"2 2 "<<n-4;else
{
for(int i=3;i<=n-4;i++)
if(zhishu(i))
{
for(int j=i;j<=n-i-2;j++)
if(zhishu(j))
{
if(zhishu(n-i-j))
{cout<<i<<" "<<j<<" "<<n-i-j;return 0;
}
}
}
}
}
by czk15 @ 2017-07-29 12:28:39
我也过了(程序跟之前很像.....)
#include<bits/stdc++.h>
using namespace std;
int ss(int n)
{
if(n==0||n==1) return 0;
for(int i=2;i<=sqrt(n);i++)
if(n%i==0) return 0;
return 1;
}
int main()
{
int n;
cin>>n;
for(int i=2;i<=n-4;i++)
if(ss(i))
for(int j=2;j<=n-i-2;j++)
if(ss(n-i-j)&&ss(j)){
cout<<i<<" "<<j<<" "<<n-i-j;
return 0;}
}
by zhangyuxing @ 2017-08-13 16:32:17
我也30
by Chris韩梦倩 @ 2017-08-15 18:45:48
我也过了
#include<bits/stdc++.h>
using namespace std;
bool prime(int x){
if(x<=1)return false;
for(int i=2;i*i<=x;i++){
if(x%i==0){
return false;
}
}
return true;
}
int main()
{
int n;
cin>>n;
int t=0;
for(int i=2;3*i<=n;i++){
for(int j=i;2*j<=n-i;j++){
if(prime(i)&&prime(j)&&prime(n-i-j)){
cout<<i<<' '<<j<<' '<<n-i-j<<endl;
return 0;
}
}
}
return 0;
}
by 起名真的很难 @ 2017-08-22 22:58:35
我也过了,跟你们很像
#include<bits/stdc++.h>
using namespace std;
int n;
int prime(int n)
{
for(int i=2;i<=sqrt(n);i++)
if(!(n%i))return 0;
return 1;
}
int main()
{
scanf("%d",&n);
for(int i=2;i<=n/3;i++)
for(int j=i;j<=n/3;j++)
if(prime(i)&&prime(j)&&prime(n-i-j))
{printf("%d %d %d",i,j,n-i-j);return 0;}
}
by jixinhong @ 2017-08-25 12:29:23
我也过了(不要在意那个棕名)
#include <iostream>
using namespace std;
bool zs(int n)
{
if(n<2) return 0;
for(int i=2;i*i<=n;i++)
if(n%i==0) return 0;
return 1;
}
int main()
{
int n;
cin>>n;
for (int a=2;a<=n-4;a++)
{
if (!zs(a)) continue;
for (int b=2;b<=n-a-2;b++)
{
if (!zs(b)) continue;
int c=n-a-b;
if (zs(c)) {cout<<a<<' '<<b<<' '<<c;return 0;}
}
}
return 0;
}