Error message of HDU 2068 RPG

Source: Internet
Author: User

At first, my idea was to fix the half. The other half was added to the combination formula Cn1 + cn2 + cn3 + CN4 +... + CNI. Finally, we could subtract them from the full arrangement.

Finally, we found that the train of thought was totally wrong. We had to use the wrong sorting formula for calculation.

That is, CNM * A [n-M]; select m from N people, and use the wrong rank formula to calculate the number of N-m people that are not in the corresponding position.

The result is displayed based on the principle of step-by-step counting.

 

# include
double zuhe (int n, int m)
{< br> double S = 1, I;
for (I = 0; I S = S * (N-I)/(I + 1);
return S;
}< br> int main ()
{< br> int n, m, I;
double s [26], sum;
S [1] = 0; s [2] = 1;
for (I = 3; I <26; I ++)
S [I] = (I-1) * (s [I-1] + s [I-2]);
while (scanf ("% d", & N) = 1 & n! = 0)
{< br> sum = 0;
If (N % 2 = 0)
M = n/2;
else
M = (n + 1)/2;
for (I = m; I sum = sum + zuhe (n, I) * s [n-I];
printf ("%. LF \ n ", sum + 1);
}< br> return 0;
}

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.