HDU 2152-Fruit (primary function)
FruitTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 3320 Accepted Submission (s): 1885
Problem Description in the twinkling of an eye to the harvest season, due to the professional guidance of TT, Lele has gained a great harvest. In particular, there are N types of fruits in Lele, including apples, pears, bananas, and watermelons ...... It not only tastes delicious, but also looks nice.
As a result, many people come here to find Lele to buy fruit.
Even the well-known hdu acm Director lcy came. Lcy throws a dozen dollar notes. "I want to buy a fruit platter consisting of M fruits, but I have a small requirement that I have a limit on the number of each fruit, which cannot be less than a specific value, it cannot be greater than a specific value. And I don't want two identical disks. If you can match them at will, I will buy as many different solutions as you can! "
Now, please help Lele and help him calculate how many fruit disks can be sold to lcy.
Note that fruit is a basic unit and cannot be further divided. For the two schemes, if the numbers of fruits are the same, the two schemes are considered to be the same.
Lele eventually took the money and can continue his studies ~
Input this question contains multiple groups of tests. Please process it until the end of the file (EOF ).
The first line of each group of tests contains two positive integers N and M. Next, there are N rows of fruit information. Each row has two integers, A and B (0 <= A <= B <= 100), indicating that at least one fruit is required, you can only buy up to B fruits.
For each group of tests, Output the total number of solutions that can be sold in one row.
Ensure that the answer is less than 10 ^ 9
Sample Input
2 31 21 23 50 30 30 3
Sample Output
212 this question is not bad .. The unit price of each fruit can be regarded as 1, and then m fruits are required to calculate the number of combinations whose value is m.#include #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long long#define maxn 116#define pp pair
#define INF 0x3f3f3f3f#define max(x,y) ( ((x) > (y)) ? (x) : (y) )#define min(x,y) ( ((x) > (y)) ? (y) : (x) )using namespace std;int n,m,a[maxn],b[maxn],num_low[maxn],num_up[maxn];void solve(){memset(a,0,sizeof(a));a[0]=1;for(int i=0;i