#include<bits/stdc++.h>
using namespace std;
int used[6], num[6];
bool flag = false;
void biject(int pos, int sum)
{
if(flag == true)
return;
if(pos == 5)
{
if(sum == 23)
flag = true;
return;
}
for(int i=1; i<=5; i++)
{
if(used[i] == 0)
{
used[i] = 1;
biject(pos+1, sum + num[i]);
biject(pos+1, sum - num[i]);
biject(pos+1, sum * num[i]);
used[i] = 0;
}
}
}
int main()
{
while(cin >> num[1] >> num[2] >> num[3] >> num[4] >> num[5])
{
if(num[1] == 0 && num[2] == 0 && num[3] == 0 && num[4] == 0 && num[5] == 0)
break;
flag = false;
for(int i=1; i<=5; i++)
{
used[i] = 1;
biject(1, num[i]);
used[i] = 0;
}
if(flag == true)
cout << "Possible" << "\n";
else
cout << "Impossible" << "\n";
}
return 0;
}
Comments
Post a Comment