fork download
  1. #define _CRT_SECURE_NO_DEPRECATE
  2. //freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
  3. //DEUX_COPY_RIGHTS_RESERVED
  4. #include <stdio.h>
  5. #include <iostream>
  6. #include <algorithm>
  7. #include <string>
  8. #include <cmath>
  9. #include <math.h>
  10. #include <sstream>
  11. #include <vector>
  12. #include <sstream>
  13. #include <cstdio>
  14. #include <set>
  15. #include <stack>
  16. #include <queue>
  17. #include <time.h>
  18. #include <map>
  19. #include <algorithm>
  20. #include <iomanip>
  21. #include <unordered_map>
  22. #include <list>
  23. #include <time.h>
  24. #define ss stringstream
  25. #define all(T) T.begin() , T.end()
  26. #define allr(T) T.rbegin() , T.rend()
  27. #define pii pair<int ,int >
  28. #define ll long long
  29. #define uint unsigned int
  30. #define vi vector<ll>
  31. #define ef else if
  32. #define re return
  33. using namespace std;
  34. #define rep2(n,m) for(int i= 0 ; i<n ; i++) for(int j= 0 ; j<m ; j++)
  35. #define repr(a,b) for( int i =a ;i< b ;i++)
  36. #define rep(n) for(int i= 0 ; i<n ; i++)
  37. #define rrep(n) for(int i= n-1 ; i >-1 ; i--)
  38. #define rep1(n) for (int i=1 ;i<=n ;i++)
  39. #define repit(cont) for ( auto it = cont.begin() ; ; it++)
  40. #define rrepit(cont) for ( auto it = cont.rbegin() ;it!= cont.rend() ; it++)
  41. #define repitr(a,b) for ( auto it = a ; it!= b ; it++)
  42.  
  43. ll OO = 10e9;
  44.  
  45.  
  46. int arr[1000] ;
  47. bool vis[1000] ;
  48.  
  49. bool make_comb( int s , int lvl , int n ) {
  50.  
  51. if ( lvl == n )
  52. { if (s== 23)
  53. re 1 ;
  54. else
  55. re 0;
  56. }
  57. rep(n){
  58.  
  59. if(! vis[i] )
  60. {
  61. vis[i] = 1 ;
  62. if( make_comb (s+arr[i] , lvl+1,n) ) re 1;
  63. if ( lvl != 0 && make_comb (s-arr[i] ,lvl+1,n)) re 1 ;
  64. if ( lvl != 0 && make_comb (s*arr[i] ,lvl+1,n) ) re 1;
  65. vis[i] = 0 ;
  66. }
  67. }
  68. re 0;
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. template <class T >
  77. T* mem_set ( T* arr , int val , uint size ) {
  78. rep(size)
  79. arr[i] = val ;
  80. re arr ;
  81. }
  82.  
  83. int main ()
  84.  
  85.  
  86. {
  87.  
  88. //freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
  89.  
  90. while (1)
  91.  
  92. {
  93.  
  94. mem_set(vis, 0, 5) ;
  95. rep(5)
  96. cin>> arr[i] ;
  97. bool flag0 =1 ;
  98. rep(5)
  99. if (arr[i] != 0 ) flag0 = 0;
  100.  
  101. if(flag0)
  102. break ;
  103.  
  104. bool f = 0;
  105. sort ( arr , arr +5 ) ;
  106.  
  107. f = make_comb(0,0,5) ;
  108.  
  109. if ( f)
  110. cout << "Possible\n" ;
  111. else
  112. cout<< "Impossible\n" ;
  113.  
  114. }
  115. re 0 ;
  116.  
  117. }
Success #stdin #stdout 0s 3100KB
stdin
Standard input is empty
stdout
Standard output is empty