/// Integer sharding template // g (x) = (1 + x ^ 2 ...) (1 + x ^ 2 + x ^ 4 ...) (1 + x ^ 3 + x ^ 6 ...) # include <stdio. h> # include <algorithm> # include <string. h ># include <iostream> using namespace STD; int main () {int N, I, J, K, c1 [125], C2 [125]; while (~ Scanf ("% d", & N) {// initialization, corresponding to the first expression (1 + x ^ 2 ....), this is only one case between (0, n) I for (I = 0; I <= N; I ++) {c1 [I] = 1; /// Save the number of numbers that can be combined. C2 [I] = 0; // intermediate quantity, save every time} // start from the second expression for (I = 2; I <= N; I ++) {for (j = 0; j <= N; j ++) // J from 0 to N enumeration {for (k = 0; k + j <= N; k + = I) /// enumerate the exponent of expression I from K. The exponential increment of expression I is I {c2 [K + J] + = c1 [J];} for (j = 0; j <= N; j ++) // assign the value of C2 to C1, because every time C2 starts from another expression, {c1 [J] = c2 [J]; c2 [J] = 0 ;}} printf ("% d \ n ", c1 [N]);} return 0 ;}
HDU 1028 Ignatius and the princess III (primary function)