| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
那位大牛帮看看啊,实在不知道错那里了#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define s 10000
int x[21],y[21];
int f1[2*s];
int f2[2*s];
int main()
{
int c,g,i,j,k,min=0,max=0;
while(scanf("%d%d",&c,&g)==2)
{
min=0,max=0;
for(i=0;i<c;i++)
scanf("%d",x+i);
for(i=0;i<g;i++)
{
scanf("%d",y+i);
min+=y[i],max+=y[i];
}
min=min*x[0],max=max*x[c-1];
memset(f1,0,sizeof(f1));
memset(f2,0,sizeof(f2));
for(i=0;i<g;i++)
{
for(j=0;j<c;j++)
{
int temp;
temp=y[i]*x[j];
f2[temp+s]++;
for(k=min;k<=max;k++)
if(k+temp>=min && k+temp<=max && f1[k+s])
f2[k+temp+s]+=f1[k+s];
}
memcpy(f1,f2,sizeof(f2));
memset(f2,0,sizeof(f2));
}
printf("%d\n",f1[s]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator