1 #include <iostream>
2 #include <cstring>
3 #include <cmath>
4 using namespace std;
5 const double x = 1e-6;
6
7 double a[5];
8
9 bool dfs(int step)
10 {
11 int i,j,k,t;
12 if(step == 1)
13 {
14 if(fabs(a[0]-24)< x)
15 return 1;
16 else
17 return 0;
18 }
19 else
20 {
21 double m,n;
22 for(i=0;i<step;i++)
23 for(j=i+1;j<step;j++)
24 {
25 m = a[i],n = a[j];
26 a[j] = a[step - 1];
27 for(k=1;k<=6;k++)
28 {
29 // m = a[i],n = a[j];
30 // a[j] = a[step - 1];
31 switch (k)
32 {
33 case 1:a[i] = m+n;
34 if(dfs(step-1)) return 1;
35 break;
36 case 2:a[i] = m-n;
37 if(dfs(step-1)) return 1;
38 break;
39 case 3:a[i] = n-m;
40 if(dfs(step-1)) return 1;
41 break;
42 case 4:a[i] = m*n;
43 if(dfs(step-1)) return 1;
44 break;
45 case 5:
46 if(fabs(n)>=x)
47 {
48 a[i] = m/n;
49 if(dfs(step-1)) return 1;
50 break;
51 }
52 case 6:
53 if(fabs(m)>=x)
54 {
55 a[i] = n/m;
56 if(dfs(step-1)) return 1;
57 break;
58 }
59 }
60 }
61 a[i] = m,a[j] = n;
62 }
63 }
64 return 0;//忘啦
65 }
66
67 int main()
68 {
69 int i,j,k,t;
70 while(1)
71 {
72 memset(a,0,sizeof(a));
73 double sum = 0;
74 for(i=0;i<4;i++)
75 {
76 cin>>a[i];
77 sum += a[i];
78 }
79 bool flag ;
80 if(0==sum)
81 break;
82 else
83 flag = dfs(4);
84 if(flag)
85 cout<<"YES"<<endl;
86 else
87 cout<<"NO"<<endl;
88 }
89 return 0;
90 }