给出不大于10的正整数,可以不分顺序的加,减,乘,除,看结果能否得到24
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
int f;
double go[10];
bool hi[10];
int mine;
void make(double k)
{
//cout<<k<<endl;
int i,j=1;
for (i=0;i<4;i++)
{
if (!hi[i])
{
j=0;
hi[i]=true;
make(k+go[i]);
make(abs(k-go[i]));
make(k*go[i]);
make(k/go[i]);
hi[i]=false;
}
}
if (j)
{
//cout<<k<<endl;
if (abs(k)==24)
f=1;
}
}
int main()
{
freopen("fuck.txt","r",stdin);
int i,j,k;
while (cin>>go[0]>>go[1]>>go[2]>>go[3])
{
mine=100;
memset(hi,0,sizeof(hi));
f=0;
for (i=0;i<4;i++)
{
hi[i]=true;
make(go[i]);
hi[i]=false;
}
if (f)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}