hdu 1085 Holding Bin-Laden Captive! 母函数

来源:互联网 发布:衡阳软件培训 编辑:程序博客网 时间:2024/04/29 05:18
#include<iostream>using namespace std;const int Max = 1000 + 1000*2 + 1000*5 + 10;int c1[Max], c2[Max], c3[Max];int main(){int a, b, c;while(scanf("%d%d%d", &a, &b, &c) && (a||b||c) ){memset(c1, 0, sizeof(c1));memset(c2, 0, sizeof(c2));memset(c3, 0, sizeof(c3));int i, j;for( i=0; i <= a; i++ )c1[i] = 1;for( i=0; i <= a; i++ )for( j=0; j <= 2*b; j+=2 )c2[j+i] += c1[i];for( i=0; i <= a+2*b; i++ )for( j=0; j <= 5*c; j+=5)c3[j+i] += c2[i];for( i=0; i <= Max-10; i++ ){if(c3[i]==0)break;}printf("%d\n", i);}return 0;}