Miyu original, post Please note: Reprinted from __________ White House
Question address:
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2068
Description:Problem description
This summer, hangdian ACM training team formed the first girl team, one of which is called RPG. However, as a member of the training team, camels did not know who the three RPG players are. RPG gave him the opportunity to guess, the first guess: R is the princess, p is the grass, G is the moon hare; the second guess: R is the grass, p is the moon hare, G is the princess; the third guess: R is the grass, p is the princess, G is the moon hare; the sixth time the poor wild camels finally divided the RPG clearly. Thanks to RPG, there are more and more girls working on ACM. Our wild camels want to know about them, but now there are n people who want to guess more times. In order not to embarrass the wild camels, if a girl asks him to pass the examination only by half or more, how many answers can he pass the examination smoothly.
Input
There are multiple cases in the input data, each of which includes one n, representing several girls, (n<=25), N=Input 0 ends.
Sample Input
1
2
0
Sample output
1
1
Obviously, the problem of incorrect sorting + arrangement and combination. For more error sorting information, click --> <incorrect sorting formula>
If you want to guess about half or half of a person's right, take the person less than or equal to n/2 from the given n people for the wrong sorting,
Because the question is about all the solutions for smooth customs clearance, we need to accumulate the error sorting method of 0-> n/2.
Incorrect sorting formula:F (n) = (n-1) * (f (n-1) + f (n-2 ))
Code As follows:// Original miyu, please note: Reprinted from __________ White House
# Include < Stdio. h >
Typedef Long Long Int64;
Int64 COM ( Int N, Int M) // The number of combinations of CN m
{
If (M = 0 )
{
Return 1 ;
}
Int64 up = 1 , Down = 1 ;
For ( Int I = 0 ; I < M; ++ I)
{
Up * = N - I;
Down * = I + 1 ;
}
Return Up / Down;
}
Int64 f [ 14 ] = { 0 , 0 , 1 , 2 };
Void Setnum ()
{
For ( Int I = 4 ; I < 14 ; ++ I)
{
F [I] = (I - 1 ) * (F [I - 1 ] + F [I - 2 ]);
}
}
Int Main ()
{
Int N;
Int64 sum;
Setnum ();
While (Scanf ( " % D " , & N), n)
{
Sum = 1 ;
For ( Int I = N / 2 ; I > = 0 ; -- I)
{
Sum + = COM (n, I) * F [I]; // The number of I-person error rows from N
}
Printf ( " % I64d \ n " , Sum );
}
}