FruitTime
limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 3899 Accepted Submission (s): 2217
Problem description in the twinkling of an eye to harvest season, due to the professional guidance of TT, Lele obtained a great harvest. In particular, fruit, lele a total of n species of fruit, apples, pears, bananas, watermelon ... Not only is the taste delicious, but also looks good.
So, a lot of people come to Lele to buy fruit.
Even the famous HDU ACM Chief Coach LCY also came. LCY throws a dozen hundred dollar bills, "I want to buy a fruit platter composed of M fruit, but I have a small request, for each kind of fruit, I have a limit on the number, can not be less than a certain value, and cannot be greater than a certain value." And I don't want two copies of the same platter. How many different options can you mix, and how many will I buy? "
Now ask you to help Lele, help him figure out how many servings of fruit platter can be sold to LCY.
Note that the fruit is based on a basic unit and cannot be divided. For both scenarios, if the number of fruits is the same, the two scenarios are considered to be the same.
Finally Lele took the money, and can continue his studies ~
Input This topic contains multiple sets of tests, please process to end of file (EOF).
The first line of each group of tests consists of two positive integers N and M (meaning see topic Description, 0<N,M<=100)
Next there is n rows of fruit information, each line of two integers a, b (0<=a<=b<=100), indicating that at least to buy the fruit of a, at most can only buy the fruit B.
Output for each set of tests, outputs the total number of scenarios that can be sold in a row.
The question data guarantees that the answer is less than 10^9
Sample Input
2 31 21 23 50 30 30 3
Sample Output
212
Authorlinle
SOURCEACM Program Design Final Exam--2008-01-02 (3 teaches 417)
Recommendlcy | We have carefully selected several similar problems for you:1171 1709 2110 2079 2189
Note Initialize the range of values.
#include <stdio.h> #include <string.h> #include <algorithm>using namespace Std;int c1[10010];int c2[ 10010];int n,m;struct num{int x, y;} Num[10010];int max,min,maxn;int generation () {memset (c1,0,sizeof (C1)); memset (c2,0,sizeof (C2)); for (int i=num[1].x;i <=num[1].y;i++) {c1[i]=1;} for (int i=2;i<=n;i++) {for (int. j=0;j<=m;j++) {for (int k=num[i].x;k+j<=m&&k<=num[i].y;k++) c2[j+k ]+=C1[J];} for (int j=0;j<=m;j++) {c1[j]=c2[j];c2[j]=0;}} return c1[m];} int main () {while (scanf ("%d%d", &n,&m)!=eof) {maxn=0;for (int i=1;i<=n;i++) {scanf ("%d%d", &num[i].x, &NUM[I].Y);} printf ("%d\n", Generation ());} return 0;}
Copyright NOTICE: This article is the original blogger articles, reproduced please indicate the source.
Hdoj Fruit 2152 "female function"