[恢]hdu 2152
2011-12-30 16:20:20
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2152
题意:中文。
mark:dp搞起。
代码:
# include <stdio.h>
# include <string.h>
int dp[110][110] ;
int main ()
{
int n, m, a, b, i, j, k ;
while (~scanf ("%d%d", &n, &m))
{
memset (dp, 0, sizeof(dp)) ;
dp[0][0] = 1 ;
for (i = 1 ; i <= n ; i++)
{
scanf ("%d%d", &a, &b) ;
for (j = 0 ; j <= m ; j++)
{
dp[i][j] = 0 ;
for (k = a ; k <= b && j-k >= 0; k++)
dp[i][j] += dp[i-1][j-k] ;
}
}
printf ("%d\n", dp[n][m]) ;
}
return 0 ;
}