# * Dislocation arrangement of the envelope problem

Source: Internet
Author: User
Tags time limit

Problem A
Time limit:1000 MS Memory limit:32 MB 64bit IO Format:%i64d
Submitted:64 accepted:28
[Submit] [Status] [Web Board]
Description

We often feel that to do a good thing is really not easy, indeed, failure is much easier than success.
Doing "One" thing is not easy, if you want to always succeed and always never fail, it is even more difficult, like spending money is always easier than the truth.
That said, I still want to tell you that it is not easy to fail to a certain extent. For example, when I was in high school, there was a magical girl, in the English exam, unexpectedly put 40 single-choice questions all wrong. Everyone has learned probability theory, should know the probability of this situation, so far I think this is a magical thing. If we apply a classic comment, we can conclude that it is not difficult for a person to do a wrong choice, and it is difficult to do all wrong.

Unfortunately, this small probability event has happened again, and it's around us:
The thing is this--hdu has a network name called 8006 Male classmates, make countless friends, recently the classmate played a romantic, at the same time to n a Netizen each wrote a letter, this is nothing, it is, he unexpectedly put all the letters are loaded the wrong envelope. Watch out, it's all loaded wrong yo.

Now the question is: please help the poor 8006 students to calculate the total number of possible wrong ways.

Input

The input data contains more than one test instance, one row per test instance, and each row contains a positive integer n (1

#include <stdio.h> int main () {long long n,i,s[30];
while (scanf ("%i64d", &n)!=eof) {if (n>1&&n<=20)//completely can not {s[1]=0;
S[2]=1;
for (i=3; i<=n; i++) {s[i]= (i-1) * (S[i-1]+s[i-2]);

} printf ("%i64d\n", S[n]);
}} return 0; }
Related Keywords:

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.