标签:des style blog http io ar color os sp
2 2 2 1 2 2 1 40 8 1 1 2 2 3 2 4 2 5 8 6 9 7 6 8 8
2 445
#include<stdio.h>
#include<string.h>
int c[45],s[45];
int a[8],b[8];
int main()
{
int T,i,j,t,n,k;
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&n,&k);
memset(a,0,sizeof(a));
memset(s,0,sizeof(s));
for(i=0;i<k;i++)
scanf("%d%d",&a[i],&b[i]);
for(i=0;i<=n&&i<=a[0]*b[0];i+=a[0])
s[i]=1;
for(i=1;i<k;i++)
{
for(j=0;j<=n;j++)
{
for(t=0;t+j<=n&&t<=a[i]*b[i];t+=a[i])
c[j+t]+=s[j];
}
for(j=0;j<=n;j++)
{
s[j]=c[j];
c[j]=0;
}
}
printf("%d\n",s[n]);
}
return 0;
} 标签:des style blog http io ar color os sp
原文地址:http://blog.csdn.net/hdd871532887/article/details/41463893