标签:母函数hdoj ruit
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3743 Accepted Submission(s): 2121
2 3 1 2 1 2 3 5 0 3 0 3 0 3
2 12#include<cstdio> #include<cstdlib> #include<cstring> using namespace std; int c1[110],c2[110]; int a[110],b[110]; int main() { int n,m,i,j,k; while(scanf("%d%d",&n,&m)!=EOF){ for(i=0;i<n;++i){ scanf("%d%d",&a[i],&b[i]); } memset(c1,0,sizeof(c1)); memset(c2,0,sizeof(c2)); for(i=a[0];i<=b[0];++i) c1[i]=1; for(i=1;i<n;++i){ for(j=0;j<=m;++j){ for(k=a[i];k+j<=m&&k<=b[i];++k){ c2[j+k]+=c1[j]; } } for(j=0;j<=m;++j){ c1[j]=c2[j]; c2[j]=0; } } printf("%d\n",c1[m]); } return 0; }
标签:母函数hdoj ruit
原文地址:http://blog.csdn.net/r1986799047/article/details/45273383