/*
Question: Give You A n, which indicates n items. There are n numbers below, which indicates the weight of n items and then weigh them. Each item has only one item, it can be seen that there are several pieces of value that cannot be claimed, and output it, occupying a single row,
When the value is not zero, the output value cannot be called and is separated by spaces...
The value that cannot be claimed includes the residual values except (directly called) and (derived from the difference .. Ps: A bit round...
In fact, it is more convenient to use dp, but to practice the primary function!
*/
[Html]
# Include "stdio. h"
# Include "string. h"
# Deprecision MAX 10008
Int main ()
{
Int a [MAX], c1 [MAX], c2 [MAX], B [MAX];
Int I, j, k, n, sum;
While (scanf ("% d", & n )! = EOF)
{
Sum = 0;
For (I = 0; I <n; I ++)
{
Scanf ("% d", & a [I]);
Sum + = a [I];
}
For (I = 1; I <= sum; I ++)
{
B [I] = 0;
C1 [I] = c2 [I] = 0;
}
For (I = 0; I <= 1; I ++)
C1 [I * a [0] = 1;
For (I = 1; I <n; I ++)
{
For (j = 0; j <= sum; j ++)
{
For (k = 0; k * a [I] + j <= sum & k <= 1; k ++)
C2 [j + k * a [I] + = c1 [j];
}
For (j = 0; j <= sum; j ++)
{
C1 [j] = c2 [j]; c2 [j] = 0;
}
} // Process of the primary function
For (I = sum; I> 0; I --)
{
If (c1 [I])
{
For (j = 1; j <I; j ++)
{
If (c1 [j])
B [I-j] = 1;
}
}
} <Span style = "COLOR: #008000"> // </span> <span style = "COLOR: #008000 "> here we use this method to find the available difference </span>
K = 0;
For (I = 1; I <= sum; I ++)
{
If (! C1 [I] &! B [I]) // store the unclaimed value into c2 ..
C2 [k ++] = I;
}
Printf ("% d \ n", k );
If (k)
{
For (I = 0; I <K-1; I ++)
Printf ("% d", c2 [I]);
Printf ("% d \ n", c2 [I]);
}
}
Return 0;
}
Author: yyf572132811