// Give you a fixed number of three coins with a nominal value of 1, 2, and 5, and find the minimum amount of money that cannot be obtained. // g (x) = (1 + x +... + x ^ num1) (1 + x ^ 2 +... + x ^ 2num2) (1 + x ^ 5 +, + x ^ 5num3), // expand, the number of coefficients not 0 can be combined by coins. # Include <algorithm> # include <string. h> # include <stdio. h ># include <iostream> using namespace STD; int main () {int I, J, K, max1; int c1 [8100], C2 [8100], A [10]; while (~ Scanf ("% d", & A [1], & A [2], & A [5]), A [1] + A [2] + A [5]) {max1 = A [1] + A [2] * 2 + A [5] * 5; for (I = 0; I <= 8100; I ++) {c1 [I] = 0; c2 [I] = 0 ;}for (I = 0; I <= A [1]; I ++) // The first coin c1 [I] = 1; for (I = 2; I <= 5; I + = 3) {for (j = 0; j <= 8100; j ++) {for (k = 0; K * I + j <= 8100 & K <= A [I]; k ++) {c2 [J + K * I] + = c1 [J];} for (j = 0; j <= 8100; j ++) {c1 [J] = c2 [J]; c2 [J] = 0 ;}} for (I = 1; I <= 8100; I ++) if (c1 [I] = 0) {printf ("% d \ n", I ); break;} return 0 ;}
HDU 1085 holding bin-Laden captive! (Primary function)