这道题也没什么好说的,直接DFS就可以了,只是要注意一句话“The aim is to use some arithmetic on (some of) the five numbers to form the target number.”,注意黑体的some of。
代码(几乎没剪枝):
int main()
{
int cases;
cin>>cases;
for (int o=0; o<cases; o++)
{
for (int i=1; i<=5; i++)
cin>>a[i];
cin>>dest;
memset(used,0,sizeof(used));
q=1000;
dfs(5);
cout<<m<<endl;
}
return 0;
}