求解释为啥爆零?
查看原帖
求解释为啥爆零?
222341
twocats楼主2020/5/24 18:38
#include<bits/stdc++.h>
using namespace std;
const int N=201,O=500001;
struct node{
	int v,n;
}money[N];
bool f[O]={1};
int n,m,x;
int main()
{
//	freopen("watch.in","r",stdin);
//	freopen("watch.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&money[i].v,&money[i].n);
		for(int j=0;j<money[i].n;j++)
		{
			for(int k=O;k>=money[i].v;k--)
			{
				f[k]=f[k-money[i].v];
			}
		}
	}
	while(m--&&scanf("%d",&x)==1)	puts(f[x]?"Yes":"No");
	return 0;
}
2020/5/24 18:38
加载中...