/*
Question: give a certain (n) Number of weights. Each weight is a1, a2, a3... An,
Question: Find [1 ~ Sum (sum is the sum of weights) cannot be weighed;
Key Issue: You can place weights on both sides of the balance,
Put on the same end: a [j + k] + = a [j] different end a [abs (j-k)] + = a [j]
Assuming that all the original weights are placed on the right side, you can place the newly added weights on the left side to obtain the new weight. In this case, a [abs (j-k)] + = a [j].
Http://acm.hdu.edu.cn/showproblem.php? Pid = 1709 click to open the link
*/
# Include <iostream> # include <cstring> # include <cmath> using namespace std; # define maxn 101 int a [maxn * maxn], B [maxn * maxn], c [maxn]; int main () {int n; while (cin> n) {int sum = 0; for (int I = 0; I <n; I ++) {cin> c [I]; sum + = c [I];} memset (a, 0, sizeof (a); memset (B, 0, sizeof (B); for (int I = 0; I <= c [0]; I + = c [0]) a [I] = 1; // int now = c [0]; for (int I = 1; I <n; I ++) // 1. I Represents the I expression {for (int j = 0; j <= sum; j ++) // 2. J indicates the I entry of each expression {for (int k = 0; k <= c [I]; k + = c [I]) // k indicates the index of item I of each expression {B [j + k] + = a [j]; B [abs (j-k)] + = a [j] ;}// now + = c [I]; for (int j = 0; j <= sum; j ++) {a [j] = B [j]; B [j] = 0 ;}} int num = 0; for (int I = 0; I <= sum; I ++) {if (! A [I]) num ++;} cout <num <endl; int p = 1; if (num) {for (int I = 0; I <= sum; I ++) {if (! A [I]) {if (! P) cout <"<I; else {cout <I; p = 0 ;}}} cout <endl ;}}}