100分代码:
(暴力解决。。大佬别嫌)
/* 2 */
#include <iostream>
#include <cstring>
using namespace std;
const int N = 10;
char s[N];
int main(void){
int n;
scanf("%d",&n);
for(int i=0; i<n; i++){
cin >> s;
int a = s[0] - '0';
int b = s[2] - '0';
int c = s[4] - '0';
int d = s[6] - '0';
int sum;
if(s[1]=='+' && s[3]=='+' && s[5]=='+'){
sum = a + b + c + d;
}else if(s[1]=='+' && s[3]=='+' && s[5]=='-'){
sum = a + b + c - d;
}else if(s[1]=='+' && s[3]=='+' && s[5]=='x'){
sum = a + b + (c * d);
}else if(s[1]=='+' && s[3]=='+' && s[5]=='/'){
sum = a + b + (c / d);
}else if(s[1]=='+' && s[3]=='-' && s[5]=='+'){
sum = a + b - c + d;
}else if(s[1]=='+' && s[3]=='-' && s[5]=='-'){
sum = a + b - c - d;
}else if(s[1]=='+' && s[3]=='-' && s[5]=='x'){
sum = a + b - (c * d);
}else if(s[1]=='+' && s[3]=='-' && s[5]=='/'){
sum = a + b - (c / d);
}else if(s[1]=='+' && s[3]=='x' && s[5]=='+'){
sum = a + (b * c) + d;
}else if(s[1]=='+' && s[3]=='x' && s[5]=='-'){
sum = a + (b * c) - d;
}else if(s[1]=='+' && s[3]=='x' && s[5]=='x'){
sum = a + (b * c) * d;
}else if(s[1]=='+' && s[3]=='x' && s[5]=='/'){
sum = a + (b * c) / d;
}else if(s[1]=='+' && s[3]=='/' && s[5]=='+'){
sum = a + (b / c) + d;
}else if(s[1]=='+' && s[3]=='/' && s[5]=='-'){
sum = a + (b / c) - d;
}else if(s[1]=='+' && s[3]=='/' && s[5]=='x'){
sum = a + (b / c) * d;
}else if(s[1]=='+' && s[3]=='/' && s[5]=='/'){
sum = a + (b / c) / d;
}else if(s[1]=='-' && s[3]=='+' && s[5]=='+'){
sum = a - b + c + d;
}else if(s[1]=='-' && s[3]=='+' && s[5]=='-'){
sum = a - b + c - d;
}else if(s[1]=='-' && s[3]=='+' && s[5]=='x'){
sum = a - b + (c * d);
}else if(s[1]=='-' && s[3]=='+' && s[5]=='/'){
sum = a - b + (c / d);
}else if(s[1]=='-' && s[3]=='-' && s[5]=='+'){
sum = a - b - c + d;
}else if(s[1]=='-' && s[3]=='-' && s[5]=='-'){
sum = a - b - c - d;
}else if(s[1]=='-' && s[3]=='-' && s[5]=='x'){
sum = a - b - (c * d);
}else if(s[1]=='-' && s[3]=='-' && s[5]=='/'){
sum = a - b - (c / d);
}else if(s[1]=='-' && s[3]=='x' && s[5]=='+'){
sum = a - (b * c) + d;
}else if(s[1]=='-' && s[3]=='x' && s[5]=='-'){
sum = a - (b * c) - d;
}else if(s[1]=='-' && s[3]=='x' && s[5]=='x'){
sum = a - (b * c) * d;
}else if(s[1]=='-' && s[3]=='x' && s[5]=='/'){
sum = a - (b * c) / d;
}else if(s[1]=='-' && s[3]=='/' && s[5]=='+'){
sum = a - (b / c) + d;
}else if(s[1]=='-' && s[3]=='/' && s[5]=='-'){
sum = a - (b / c) - d;
}else if(s[1]=='-' && s[3]=='/' && s[5]=='x'){
sum = a - (b / c) * d;
}else if(s[1]=='-' && s[3]=='/' && s[5]=='/'){
sum = a - (b / c) / d;
}else if(s[1]=='x' && s[3]=='+' && s[5]=='+'){
sum = (a * b) + c + d;
}else if(s[1]=='x' && s[3]=='+' && s[5]=='-'){
sum = (a * b) + c - d;
}else if(s[1]=='x' && s[3]=='+' && s[5]=='x'){
sum = (a * b) + (c * d);
}else if(s[1]=='x' && s[3]=='+' && s[5]=='/'){
sum = (a * b) + (c / d);
}else if(s[1]=='x' && s[3]=='-' && s[5]=='+'){
sum = (a * b) - c + d;
}else if(s[1]=='x' && s[3]=='-' && s[5]=='-'){
sum = (a * b) - c - d;
}else if(s[1]=='x' && s[3]=='-' && s[5]=='x'){
sum = (a * b) - (c * d);
}else if(s[1]=='x' && s[3]=='-' && s[5]=='/'){
sum = (a * b) - (c / d);
}else if(s[1]=='x' && s[3]=='x' && s[5]=='+'){
sum = a * b * c + d;
}else if(s[1]=='x' && s[3]=='x' && s[5]=='-'){
sum = a * b * c - d;
}else if(s[1]=='x' && s[3]=='x' && s[5]=='x'){
sum = a * b * c * d;
}else if(s[1]=='x' && s[3]=='x' && s[5]=='/'){
sum = a * b * c / d;
}else if(s[1]=='x' && s[3]=='/' && s[5]=='+'){
sum = a * b / c + d;
}else if(s[1]=='x' && s[3]=='/' && s[5]=='-'){
sum = a * b / c - d;
}else if(s[1]=='x' && s[3]=='/' && s[5]=='x'){
sum = a * b / c * d;
}else if(s[1]=='x' && s[3]=='/' && s[5]=='/'){
sum = a * b / c / d;
}else if(s[1]=='/' && s[3]=='+' && s[5]=='+'){
sum = (a / b) + c + d;
}else if(s[1]=='/' && s[3]=='+' && s[5]=='-'){
sum = (a / b) + c - d;
}else if(s[1]=='/' && s[3]=='+' && s[5]=='x'){
sum = (a / b) + (c * d);
}else if(s[1]=='/' && s[3]=='+' && s[5]=='/'){
sum = (a / b) + (c / d);
}else if(s[1]=='/' && s[3]=='-' && s[5]=='+'){
sum = (a / b) - c + d;
}else if(s[1]=='/' && s[3]=='-' && s[5]=='-'){
sum = (a / b) - c - d;
}else if(s[1]=='/' && s[3]=='-' && s[5]=='x'){
sum = (a / b) - (c * d);
}else if(s[1]=='/' && s[3]=='-' && s[5]=='/'){
sum = (a / b) - (c / d);
}else if(s[1]=='/' && s[3]=='x' && s[5]=='+'){
sum = a / b * c + d;
}else if(s[1]=='/' && s[3]=='x' && s[5]=='-'){
sum = a / b * c - d;
}else if(s[1]=='/' && s[3]=='x' && s[5]=='x'){
sum = a / b * c * d;
}else if(s[1]=='/' && s[3]=='x' && s[5]=='/'){
sum = a / b * c / d;
}else if(s[1]=='/' && s[3]=='/' && s[5]=='+'){
sum = (a / b) / c + d;
}else if(s[1]=='/' && s[3]=='/' && s[5]=='-'){
sum = (a / b) / c - d;
}else if(s[1]=='/' && s[3]=='/' && s[5]=='x'){
sum = (a / b) / c * d;
}else if(s[1]=='/' && s[3]=='/' && s[5]=='/'){
sum = (a / b) / c / d;
}
if(sum == 24){
printf("Yes\n");
}else
printf("No\n");
}
return 0;
}