Advertisement
erfanul007

10168

Dec 26th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // #pragma GCC optimize("Ofast,no-stack-protector")
  5. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  6. // #pragma GCC optimize("unroll-loops")
  7.  
  8. typedef unsigned long long ull;
  9. typedef long long ll;
  10. typedef long double lld;
  11. typedef vector<int> vi;
  12. typedef vector<ll> vll;
  13. typedef vector<vi> vvi;
  14. typedef pair<int,int > pii;
  15. typedef vector< pii > vpii;
  16. typedef set<int> sti;
  17.  
  18. #define sc scanf
  19. #define pf printf
  20. #define sci(n) scanf("%d",&n)
  21. #define scii(n,m) scanf("%d %d",&n,&m)
  22. #define scl(n) scanf("%lld",&n)
  23. #define scd(n) scanf("%lf",&n)
  24. #define scs(s) scanf("%s",s)
  25. #define pfi(n) printf("%d",n)
  26. #define pfl(n) printf("%lld",n)
  27. #define pff(n) cout<<n
  28. #define spc printf(" ")
  29. #define line printf("\n")
  30. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  31. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  32. #define cspf(i) printf("Case %d: ", i)
  33. #define vout(v) for(int w=0;w<v.size();w++){if(w) cout<<' '; cout<<v[w];}
  34. #define clr(a,x) memset(a,x,sizeof(a))
  35. #define tp(v,j) get<j>(v)
  36. #define pb push_back
  37. #define mp make_pair
  38. #define mt make_tuple
  39. #define ff first
  40. #define ss second
  41. #define all(v) v.begin(),v.end()
  42. #define rall(v) v.rbegin(),v.rend()
  43. #define read() freopen("input.txt", "r", stdin)
  44. #define write() freopen("output.txt", "w", stdout)
  45. #define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL);
  46. /// Constants
  47. #define eps 1e-6
  48. #define PI acos(-1.0) // 3.1415926535897932
  49. #define MAX (ll)2147483647
  50. #define MAXn (ll)10000001
  51.  
  52. int GCD(int a, int b) { return b == 0 ? a : GCD(b , a % b); }
  53. ll LCM(ll a, ll b) { return a * (b/GCD(a, b)); }
  54.  
  55. bool isprime[MAXn+1];
  56. vll primes;
  57.  
  58. void seive()
  59. {
  60. clr(isprime,true);
  61. isprime[0]=false;
  62. isprime[1]=false;
  63. for(int i=4;i<MAXn;i+=2) isprime[i]=false;
  64. for(int i=3;i*i<MAXn;i+=2){
  65. if(!isprime[i]) continue;
  66. for(int j=i*i;j<MAXn;j+=2*i) isprime[j]=false;
  67. }
  68.  
  69. primes.pb(2LL);
  70. for(int i=3;i<MAXn;i+=2){
  71. if(isprime[i]) primes.pb((ll)i);
  72. }
  73. }
  74.  
  75.  
  76. int main()
  77. {
  78. #ifdef VAMP
  79. clock_t tStart = clock();
  80. freopen("input.txt", "r", stdin);
  81. freopen("output.txt", "w", stdout);
  82. #endif
  83.  
  84. seive();
  85. ll x;
  86. while(~scl(x)){
  87. if(x<8LL) pf("Impossible.\n");
  88. else{
  89. bool f=false;
  90. ll a,b,c,d;
  91. if(x%2LL==0LL) a=b=2LL;
  92. else a=2LL,b=3LL;
  93. x-=(a+b);
  94. for(int i=0;primes[i]<x;i++){
  95. ll y = x-primes[i];
  96. if(isprime[y]){
  97. c=primes[i];
  98. d=y;
  99. f=true;
  100. break;
  101. }
  102. }
  103. if(f) pf("%lld %lld %lld %lld\n",a,b,c,d);
  104. else pf("Impossible.\n");
  105. }
  106. }
  107.  
  108.  
  109. #ifdef VAMP
  110. fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  111. #endif
  112.  
  113. return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement