2000sss @ 2019-04-17 20:33:59
using namespace std; int a,i,n1,n2,n3,x; int zs(int x) { for (i=2;i<=sqrt(x);i++) if (x%i==0) return 1; return 0; } int main() { cin>>a; for (n1=2;n1<=a-4;n1++) for (n2=2;n2<=a-4;n2++) { n3=a-n1-n2; if (zs(n1)+zs(n2)+zs(n3)!=0) continue; cout<<n1<<' '<<n2<<' '<<n3; return 0; } }
by vocaloid @ 2019-04-17 20:35:49
希望更丰富的展现?使用Markdown
by aminoas @ 2019-04-17 20:39:37
@2000sss
n - 2 - 2 == n - 4
by 2000sss @ 2019-04-17 20:41:49
@2018J1605 什么n-2-2?
by aminoas @ 2019-04-17 20:42:51
@2000sss 指 2 + 2 + (n - 4) == n [n - 4 为质数]
by 2000sss @ 2019-04-17 20:51:07
@2018J1605 [哭辽] 小菜鸡没懂
by Soulist @ 2019-04-17 20:54:31
@2000sss 其实也可以直接枚举两个素数,然后去判断
by 2000sss @ 2019-04-17 21:06:29
@Mital 样例的答案为啥不是2 2 2005呢?
by Soulist @ 2019-04-17 21:17:46
@2000sss
by Soulist @ 2019-04-17 21:19:19
@2000sss 假设您先求出
by 2000sss @ 2019-04-18 18:31:55
@Mital qaq 我那时候好像脑子不在线