/*
Verdict :: Accepted
*/
/// Header file begin
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <sstream>
#include <set>
#include <list>
#include <stack>
#include<utility>
#include <queue>
#include <algorithm>
/// End
//..........
/// Macro
#define sf scanf
#define pf printf
#define sfint(a,b) scanf("%d %d",&a,&b)
#define sfl(a,b) scanf("%ld %ld",&a,&b)
#define sfll(a,b) scanf("%lld %lld",&a,&b)
#define sfd(a,b) scanf("%lf %lf",&a,&b)
#define sff(a,b) scanf("%f %f",&a,&b)
#define lp1(i,n) for(i=0;i<n;i++)
#define lp2(i,n) for(i=1;i<=n;i++)
#define mem(c,v) memset(c,v,sizeof(c))
#define cp(a) cout<<" "<<a<<" "<<endl
#define nl puts("")
#define sq(x) ((x)*(x))
#define all(x) x.begin(),x.end()
#define sz size()
#define gc getchar()
#define pb push_back
/// End.........
/// Size
#define mx7 20000100
#define mx6 1500000
#define mx5 100005
#define mx4 1000100
#define inf 1<<30 //infinity value
#define eps 1e-9
#define mx 10000000
#define mod 1000000007
#define pi acos(-1.0)
/// Macros for Graph
#define white 0
#define gray 1
#define black -1
#define nil -2
using namespace std;
//..................................................................................................................
typedef long long LL;
typedef long L;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int, int> pii;
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T large(T a, T b ) {return a>b?a:b;}
template<class T> T small(T a, T b ) {return a<b?a:b;}
template<class T> T diffrnce(T a, T b) {return a-b<0?b-a:a-b;}
int prime[(mx>>6)+1],prm[(mx>>1)+1],plen=0;
#define setbit(n) (prime[n>>6]|=(1<<((n>>1)&31)))
#define checkbit(n) (prime[n>>6]&(1<<((n>>1)&31)))
void seieve(int n)
{
int i,j,x=(int)sqrt(double(n));
for(i=3;i<=x;i+=2)
{
if(!checkbit(i))
{
for(j=i*i;j<=n;j+=i+i)
{
setbit(j);
}
}
}
prm[plen++]=2;
for(i=3;i<=n;i+=2)
{
if(!checkbit(i))
{
prm[plen++]=i;
}
}
//lp1(i,plen)cp(prm[i]);
}
bool isPrime(int n)
{
if(n==2) return true;
else if(!(n&1) or n<2) return false;
else
{
return !checkbit(n);
}
return true;
}
vector<int>v;
int vlen;
void chk(int n)
{
bool f=false;
for(int i=0;i<plen;i++)
{
if((n>>1) >= prm[i])
{
int b=n-prm[i];
if(isPrime(b))
{
if(b+prm[i] == n)
{
//pf("%d %d ",prm[i],b);
v.push_back(prm[i]);
v.push_back(b);
//v[vlen++]=prm[i];
//v[vlen++]=b;
f=true;
break;
}
}
}
}
}
int main()
{
seieve(mx);
int n;
while(~sf("%d",&n))
{
if(n<=7)
{
pf("Impossible.\n");
continue;
}
if(!(n&1)) // subtract 4 if n is an even
{
int b = n-4;
chk(b);
chk(4);
}
else
{
int b=n-5; // subtract 5 if n is an odd
chk(b);
chk(5);
}
vlen=v.size();
int s=0,sp=vlen;
sort(all(v));
for(int i=0;i<vlen;i++)
{
pf("%d",v[i]);
s+=v[i];
if(sp>1)
{
pf(" ");
sp--;
}
}
//cout << " sum = " << s;
//vlen=0;
v.clear();
nl;
}
return 0;
}
Comments
Post a Comment