-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10344-3.cpp
45 lines (44 loc) · 855 Bytes
/
10344-3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int a[7];
int call(int i,int rem)
{
if(i==5)
{
if(rem==23)
return 1;
else
return 0;
}
int x=0,y=0,z=0;
z=call(i+1,rem-a[i]);
x=call(i+1,rem*a[i]);
y=call(i+1,rem+a[i]);
x=max(x,y);
z=max(x,z);
return z;
}
main()
{
int i,j=0,k;
while(scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]))
{
if(a[0]==0 && a[1]==0 && a[2]==0 && a[3]==0 && a[4]==0)
return 0;
sort(a,a+5);
do
{
k=call(1,a[0]);
if(k==1)
break;
}while(next_permutation(a,a+5));
if(k==1)
puts("Possible");
else
puts("Impossible");
}
return 0;
}