fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/tree_policy.hpp>
  6. using namespace __gnu_pbds;
  7.  
  8.  
  9. #define ull unsigned long long
  10. #define ll long long
  11. #define ff first
  12. #define ss second
  13. #define all(v) ((v).begin()), ((v).end())
  14. #define allr(v) ((v).rbegin()), ((v).rend())
  15. #define pb push_back
  16. #define iq(v) v.resize(unique(v.begin(),v.end())-v.begin())
  17. #define bye return 0
  18. #define yes cout << "YES\n"
  19. #define no cout << "NO\n"
  20. #define TC int t_t=1;cin>>t_t;while (t_t--)
  21. #define endl '\n'
  22. #define clr(v,d) memset(v,d,sizeof(v))
  23. #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  24. const ll OO = LLONG_MAX ;
  25. const ll Mod=1e9+7;
  26. const int N = 1e5+5 ;
  27. void fast()
  28. {
  29. std::ios_base::sync_with_stdio(0);
  30. cin.tie(NULL);
  31. #ifndef ONLINE_JUDGE
  32. freopen("Input.txt", "r", stdin);
  33. freopen("Output.txt", "w", stdout);
  34. #endif
  35. }
  36. int a[5] ;
  37. ll x =23 ;
  38. bool solve(int idx , ll sum)
  39. {
  40. if (idx == 5)
  41. {
  42. return sum == x ;
  43. }
  44. return solve(idx+1 , sum -=a[idx]) ||
  45. solve(idx+1 , sum +=a[idx]) ||
  46. solve(idx+1 , sum *=a[idx]) ;
  47. }
  48. int main() {
  49. fast();
  50. while (1)
  51. {
  52. cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4] ;
  53. if ( a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0 && a[4] == 0 ) return 0 ;
  54. sort(a,a+5) ;
  55. bool ok = false ;
  56. do {
  57. if (solve(1, a[0]))
  58. {
  59. ok = 1 ;
  60. break ;
  61. }
  62. }
  63. while (next_permutation(a,a+5)) ;
  64. if (ok)
  65. cout << "Possible\n" ;
  66. else
  67. cout << "Impossible\n" ;
  68. }
  69. return 0;
  70. }
Success #stdin #stdout 0.01s 5312KB
stdin
1 1 1 1 1
1 2 3 4 5
2 3 5 7 11
0 0 0 0 0
stdout
Impossible
Possible
Possible