fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  4. typedef long long ll;
  5. typedef double dd;
  6. #define pb push_back
  7. #define mp make_pair
  8. #define endl "\n"
  9. ll const M = 1000000007;
  10. dd const pi = acos(-1);
  11. ll const inf = 2e18;
  12. ll const N = 200001;
  13. vector<ll> a(5);
  14. vector<char> op = {'+','-','*'};
  15. string s;
  16. bool ok;
  17. ll calculate()
  18. {
  19. ll i,ans = 0;
  20. if(s[0] == '+')
  21. ans = a[0] + a[1];
  22. else if(s[1] == '-')
  23. ans = a[0] - a[1];
  24. else
  25. ans = a[0]*a[1];
  26. for(i = 1; i < 4; i++)
  27. {
  28. if(s[i] == '+')
  29. ans = ans + a[i + 1];
  30. else if(s[i] == '-')
  31. ans = ans - a[i + 1];
  32. else
  33. ans = ans*a[i + 1];
  34. }
  35. return ans;
  36. }
  37. void solve(ll i)
  38. {
  39. if(i == 4)
  40. {
  41. if(calculate() == 23)
  42. ok = true;
  43. return;
  44. }
  45. for(ll j = 0; j < 3; j++)
  46. {
  47. s.pb(op[j]);
  48. solve(i + 1);
  49. s.pop_back();
  50. }
  51. }
  52. int main()
  53. {
  54. fast;
  55. ll i,j,t;
  56. while(1)
  57. {
  58. for(i = 0; i < 5; i++)
  59. cin >> a[i];
  60. for(i = 0; i < 5; i++)
  61. if(a[i] != 0)
  62. break;
  63. if(i == 5)
  64. break;
  65. s.clear();
  66. sort(a.begin(),a.end());
  67. ok = false;
  68. do {
  69. solve(0);
  70. if(ok)
  71. break;
  72. } while (next_permutation(a.begin(),a.end()));
  73. if(ok)
  74. cout<<"Possible"<<endl;
  75. else
  76. cout<<"Impossible"<<endl;
  77.  
  78. }
  79. return 0;
  80. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
        ^
Main.java:3: error: illegal character: '#'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        ^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
                                              ^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
                                                            ^
Main.java:5: error: class, interface, or enum expected
typedef double dd;
^
Main.java:6: error: illegal character: '#'
#define pb push_back
^
Main.java:6: error: class, interface, or enum expected
#define pb push_back
        ^
Main.java:7: error: illegal character: '#'
#define mp make_pair
^
Main.java:8: error: illegal character: '#'
#define endl "\n"
^
Main.java:10: error: class, interface, or enum expected
dd const pi = acos(-1);
^
Main.java:11: error: class, interface, or enum expected
ll const inf = 2e18;
^
Main.java:12: error: class, interface, or enum expected
ll const N = 200001;
^
Main.java:13: error: class, interface, or enum expected
vector<ll> a(5);
^
Main.java:14: error: class, interface, or enum expected
vector<char> op = {'+','-','*'};
^
Main.java:15: error: class, interface, or enum expected
string s;
^
Main.java:16: error: class, interface, or enum expected
bool ok;
^
Main.java:17: error: class, interface, or enum expected
ll calculate()
^
Main.java:20: error: class, interface, or enum expected
	if(s[0] == '+')
	^
Main.java:22: error: class, interface, or enum expected
	else if(s[1] == '-')
	^
Main.java:24: error: class, interface, or enum expected
	else
	^
Main.java:26: error: class, interface, or enum expected
	for(i = 1; i < 4; i++)
	^
Main.java:26: error: class, interface, or enum expected
	for(i = 1; i < 4; i++)
	           ^
Main.java:26: error: class, interface, or enum expected
	for(i = 1; i < 4; i++)
	                  ^
Main.java:30: error: class, interface, or enum expected
		else if(s[i] == '-')
		^
Main.java:32: error: class, interface, or enum expected
		else
		^
Main.java:34: error: class, interface, or enum expected
	}
	^
Main.java:36: error: class, interface, or enum expected
}
^
Main.java:43: error: class, interface, or enum expected
		return;
		^
Main.java:44: error: class, interface, or enum expected
	}
	^
Main.java:45: error: class, interface, or enum expected
	for(ll j = 0; j < 3; j++)
	              ^
Main.java:45: error: class, interface, or enum expected
	for(ll j = 0; j < 3; j++)
	                     ^
Main.java:48: error: class, interface, or enum expected
		solve(i + 1);
		^
Main.java:49: error: class, interface, or enum expected
		s.pop_back();
		^
Main.java:50: error: class, interface, or enum expected
	}
	^
Main.java:55: error: class, interface, or enum expected
  	ll i,j,t;
  	^
Main.java:56: error: class, interface, or enum expected
  	while(1)
  	^
Main.java:58: error: class, interface, or enum expected
  		for(i = 0; i < 5; i++)
  		           ^
Main.java:58: error: class, interface, or enum expected
  		for(i = 0; i < 5; i++)
  		                  ^
Main.java:60: error: class, interface, or enum expected
  		for(i = 0; i < 5; i++)
  		^
Main.java:60: error: class, interface, or enum expected
  		for(i = 0; i < 5; i++)
  		           ^
Main.java:60: error: class, interface, or enum expected
  		for(i = 0; i < 5; i++)
  		                  ^
Main.java:63: error: class, interface, or enum expected
  		if(i == 5)
  		^
Main.java:65: error: class, interface, or enum expected
  		s.clear();
  		^
Main.java:66: error: class, interface, or enum expected
  		sort(a.begin(),a.end());
  		^
Main.java:67: error: class, interface, or enum expected
  		ok = false;
  		^
Main.java:68: error: class, interface, or enum expected
  		do { 
  		^
Main.java:70: error: class, interface, or enum expected
        	if(ok)
        	^
Main.java:72: error: class, interface, or enum expected
        } while (next_permutation(a.begin(),a.end())); 
        ^
Main.java:73: error: class, interface, or enum expected
  		if(ok)
  		^
Main.java:75: error: class, interface, or enum expected
  		else
  		^
Main.java:78: error: class, interface, or enum expected
  	}
  	^
Main.java:80: error: class, interface, or enum expected
}    
^
54 errors
stdout
Standard output is empty