影子鱼llt @ 2018-08-29 21:01:19
#include<stdio.h>
#include<math.h>
int prime[100000];
bool notp[700000000];//notprime
void findprime(int maxn)//埃氏筛
{
for(int i = 2;i <= maxn;i++)
{
if(notp[i]) continue;
for(int j = 2;j <= maxn;j++)
{
if(i*j > maxn) break;
notp[i*j] = true;
}
}
}
int main()
{
int n;
scanf("%d",&n);
notp[0] = notp[1] =true;
findprime(n);
int x = 0;
for(int i = 0;i <= n;i++)
if(!notp[i] && i != 0 && i != 1)
prime[x++] = i;
for(int i = 0;i < x;i++)
{
for(int j = 0;j < x;j++)
{
if(!notp[n - prime[i] - prime[j]])
{
printf("%d %d %d",prime[i],prime[j],n - prime[i] - prime[j]);
return 0;
}
}
}
return 0;
}
by wxy_god @ 2018-08-29 21:05:21
@林乐天
by 影子鱼llt @ 2018-08-29 22:04:50
@我是一个垃圾 没
by 影子鱼llt @ 2018-08-29 22:05:47
https://www.luogu.org/recordnew/show/10309827
by 影子鱼llt @ 2018-08-29 23:36:15
成功了,谢谢