Error message of hdoj HDU 2068 rpg acm 2068 in HDU

Source: Internet
Author: User
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 );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.