疯狂dp走一发
dp[i][j]代表前i种取j个
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string.h>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long int ll;
const int maxn =1e5+5;
const int maxm=10000;
const int mod =1e9+7;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
int n,m;
ll dp[25][120];
int main()
{
scanf("%d%d",&n,&m);
dp[0][0]=1ll;
for(int i=1;i<=n;i++)
{
int l,r;scanf("%d%d",&l,&r);
for(int j=0;j<=m;j++)
for(int k=l;k<=r;k++)
dp[i][j+k]+=dp[i-1][j];
}
printf("%lld\n",dp[n][m]);
return 0;
}