hdu 2079 选课时间(题目已修改,注意读题)

http://acm.hdu.edu.cn/showproblem.php?pid=2079

背包

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 3000
using namespace std; int dp[maxn];
int a,b;
int t,n,k; int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
memset(dp,,sizeof(dp));
dp[]=;
for(int i=; i<=k; i++)
{
scanf("%d%d",&a,&b);
for(int j=n; j>=a; j--)
{
for(int x=; x<=b; x++)
{
if(j-x*a>=)
{
dp[j]+=dp[j-x*a];
}
}
}
}
printf("%d\n",dp[n]);
}
return ;
}
上一篇:第11.18节 Python 中re模块的匹配对象


下一篇:oracle 查看表空间使用情况