/*I lv ya*/
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N = 2e5+5;
double n[4];
map <string,double> hs;
string s;
void init()
{
hs["A"]=1;
hs["2"]=2;
hs["3"]=3;
hs["4"]=4;
hs["5"]=5;
hs["6"]=6;
hs["7"]=7;
hs["8"]=8;
hs["9"]=9;
hs["10"]=10;
hs["J"]=11;
hs["Q"]=12;
hs["K"]=13;
}
bool vis[4],f=0;
stack <double> st;
void dfs(int num)
{
if(num==3)
{
for(int i=0;i<=3;i++)
{
if(!vis[i]&&abs(n[i]-24)<=0.000000001)
{
f=1;
return ;
}
}
}
for(int i=0;i<=3;i++)
{
if(!vis[i])
{
for(int j=0;j<=3;j++)
{
if(!vis[j]&&j!=i)
{
vis[j]=1;
double n1=n[i],n2=n[j];
n[i]=n1+n2;
dfs(num+1);
n[i]=n1-n2;
dfs(num+1);
n[i]=n2-n1;
dfs(num+1);
n[i]=n2*n1;
dfs(num+1);
if(abs(n2-0)>0.000000001)
{
n[i]=n1/n2;
dfs(num+1);
}
if(abs(n1-0)>0.000000001)
{
n[i]=n2/n1;
dfs(num+1);
}
vis[j]=0;
n[i]=n1;
}
}
}
}
}
void solve()
{
while(!st.empty())
{
st.pop();
}
for(int i=0;i<=3;i++)
{
vis[i]=0;
}
for(int i=0;i<=3;i++)
{
cin>>s;
n[i]=hs[s];
}
f=0;
dfs(0);
if(f)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
init();
int _;
cin>>_;
while(_--)
{
solve();
}
return 0;
}
08-22
599
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)