标签:hdu1085
1 1 3 0 0 0
4
#include <stdio.h> int main() { int a, b, c; while(scanf("%d%d%d", &a, &b, &c), a || b || c){ if(!a) printf("1\n"); else if(a + 2 * b < 4) printf("%d\n", a + 2 * b + 1); else printf("%d\n", a + 2 * b + 5 * c + 1); } return 0; }
#include <stdio.h> #include <string.h> #define maxn 8010 int c1[maxn], c2[maxn]; int main() { int a, b, c, i, j, k, sum; while(scanf("%d%d%d", &a, &b, &c), a || b || c){ memset(c1, 0, sizeof(c1)); memset(c2, 0, sizeof(c2)); for(i = 0; i <= a; ++i) c1[i] = 1; for(i = 2, sum = a + 2 * b; i <= 5; i += 3, sum += 5 * c){ for(j = 0; j <= sum; ++j) for(k = j; k <= sum; k += i) c2[k] += c1[j]; for(k = 0; k <= sum; ++k){ c1[k] = c2[k]; c2[k] = 0; } } for(i = 1; i <= sum; ++i){ if(!c1[i]){ printf("%d\n", i); break; } } } return 0; }
HDU1085 Holding Bin-Laden Captive! 【母函数】,布布扣,bubuko.com
HDU1085 Holding Bin-Laden Captive! 【母函数】
标签:hdu1085
原文地址:http://blog.csdn.net/chang_mu/article/details/38125937