[Csharp]
// Dp (full backpack)
# Include <stdio. h>
# Include <string. h>
# Define N 35000
Int dp [N];
Int main ()
{
Dp [0] = 1;
For (int I = 1; I <= 3; ++ I)
{// The backpack capacity is N, and items with a quality of I are loaded
For (int j = I; j <N; ++ j)
{
Dp [j] + = dp [j-I];
}
}
Int n;
While (scanf ("% d", & n )! = EOF)
Printf ("% d \ n", dp [n]);
Return 0;
} <Pre name = "code" class = "csharp"> // hdu 1284 lookup rule
// Give n to check the number of 2 and 3 in n.
// Read the code and watch
# Include <stdio. h>
# Include <string. h>
# Define N 35000
_ Int64 ans [N];
Int main ()
{
Int n; // Number of two I can be calculated
For (int I = 0; I <N; ++ I)
// + 1 indicates that all the values are composed of 1 (only in the case of 1)
Ans [I] = I/2 + 1;
// This line indicates the combination of 2 and 1.
// Push back from the front, it can be composed of three, for example, ans [3] indicates that the money is 3 hours
// When it is composed of 1 or 2 cent coins, it can be expressed as 0 and a 3 cent coin is added (the number of methods is
// The number of methods composed of 1, 2, and 3 when the money is 0 plus 3)
// Therefore ans [I] + = ans [I-3] + 1; do not need the + 1
For (int I = 3; I <N; ++ I) ans [I] + = ans [I-3];
// This line of ans [I] indicates the combination of 2 and 3.
// Ans [6] is equivalent to ans [6] composed of 2 and ans [6-3] composed of 1, 2 and 3.
// In this way, you can add a situation consisting of 3 points.
While (scanf ("% d", & n )! = EOF)
Printf ("% I64d \ n", ans [n]);
Return 0;
} </Pre> <br>
<Pre> </pre>
<P> </p>
<Pre> </pre>
<Br>
<P> </p>