fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. bool isprime(int n)
  5. {
  6. if(n<=1)
  7. return 0;
  8. if(n==2)
  9. return 1;
  10. if(n%2==0)
  11. return 0;
  12. for(int i=3;i*i<=n;i+=2)
  13. if(n%i==0)
  14. return 0;
  15. return 1;
  16. }
  17. signed main()
  18. {
  19. int n;
  20. cin>>n;
  21. if(isprime(n))
  22. cout<<"1\n"<<n;
  23. else if(isprime(n-2))
  24. cout<<"2\n2 "<<n-2;
  25. else
  26. {
  27. cout<<"3\n";
  28. cout<<3<<' ';
  29. n-=3;
  30. for(int i=3;i<n;i++)
  31. {
  32. bool b=0;
  33. for(int ii=3;ii<n;ii++)
  34. {
  35. if(isprime(i)&&isprime(ii)&&ii+i==n)
  36. {
  37. cout<<i<<' '<<ii;
  38. b=1;
  39. break;
  40. }
  41. }
  42. if(b)
  43. break;
  44. }
  45. }
  46. }
Success #stdin #stdout 0s 5284KB
stdin
5
stdout
1
5