标签:des style blog http io ar color os sp
2 3 1 2 1 2 3 5 0 3 0 3 0 3
2 12
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int a[100010],b[100010]; int s[100010],c[100010]; int main() { int i,j,k,t; int n,m; while(scanf("%d%d",&n,&m)!=EOF) { for(i=0;i<n;i++) { scanf("%d%d",&a[i],&b[i]); } memset(s,0,sizeof(s)); memset(c,0,sizeof(c)); for(i=a[0];i<=b[0];i++) { c[i]=1; } for(i=1;i<n;i++) { for(j=0;j<=m;j++) { for(k=a[i];k<=b[i]&&k+j<=m;k++) s[k+j]+=c[j]; } for(j=0;j<=m;j++) { c[j]=s[j]; s[j]=0; } } printf("%d\n",c[m]); } return 0; }
标签:des style blog http io ar color os sp
原文地址:http://blog.csdn.net/hdd871532887/article/details/41415217