还是水题。。
这题每个种类数目起点不为0;
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const int M = 110+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int f[2][M];
int w[M],ns[M],nm[M];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
while(cin>>n>>m)
{
memset(f,0,sizeof(f));
for(int i=1;i<=n;i++)cin>>ns[i]>>nm[i],w[i]=1;
f[0][0]=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=m;j++)f[i&1][j]=0;
for(int k=ns[i];k<=nm[i];k++)//当前种类水果选几个
for(int x=0;x+k*w[i]<=m;x++)
f[i&1][x+k*w[i]]+=f[(i-1)&1][x];
//cout<<i<<" "<<x<<" "<<k<<" "<<x+k*w[i]<<" - - "<<f[i&1][x+k*w[i]]<<" - > "<<f[(i-1)&1][x]<<endl;;
}
cout<<f[n&1][m]<<endl;
}
return 0;
}