#include <bits/stdc++.h>
using namespace std;
struct money{
int data,number;
}a[205];
int n,m,watch[100005],x,y;
bool remember[100005],ans[205],anslen;
bool SS(int l)
{
if(remember[l])return true;
for(int i=0;i<n;i++)
{
if(a[i].number>0)
for(int j=0;j<n;j++)
{
if(a[j].number<=0)break;
if(a[i].data+a[i].number==l){remember[l]=true;return true;}
}
bool ans1,ans2;
for(int i=0;i<=l/2;i++)
{
ans1=SS(i);
ans2=SS(l-i);
}
if(ans1==true&&ans2==true)return true;
else return false;
}
int main()
{
// freopen("save.in","r",stdin);
// freopen("save.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
a[i].number=0;
}
for(int i=0;i<n;i++)
{
scanf("%d%d",&x,&y);
a[i].data=x;
a[i].number=y;
}
for(int i=0;i<m;i++)
{
scanf("%d",&x);
if(SS(x)==true){
ans[anslen]=true;
anslen++;
}
}
for(int i=0;i<anslen;i++)
if(ans[i]==true)printf("Yes ");
else printf("No ");
// fclose(stdin);
// fclose(stdout);
return 0;
}
CE内容:
/tmp/compiler_f7me51_x/src: 在函数‘bool SS(int)’中:
/tmp/compiler_f7me51_x/src:28:9: 警告:empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
28 | int main()
| ^~
/tmp/compiler_f7me51_x/src:28:9: 附注:remove parentheses to default-initialize a variable
28 | int main()
| ^~
| --
/tmp/compiler_f7me51_x/src:28:9: 附注:or replace parentheses with braces to value-initialize a variable
/tmp/compiler_f7me51_x/src:29:1: 错误:a function-definition is not allowed here before ‘{’ token
29 | {
| ^
/tmp/compiler_f7me51_x/src:57:2: 错误:expected ‘}’ at end of input
57 | }
| ^
/tmp/compiler_f7me51_x/src:9:1: 附注:to match this ‘{’
9 | {
| ^
/tmp/compiler_f7me51_x/src:57:2: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
57 | }
| ^