Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 14924 accepted submission (s): 6207
Problem description we often feel that it is really not easy to do one thing well. Indeed, failure is much easier than success!
It is not easy to do the "one thing" thing well. If you want to succeed forever and never fail, it is even harder, just as spending money is always easier than making money.
Even so, 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 who did all the 40 single-choice questions wrong during the English test! Everyone has learned probability theory and should know the probability of such a situation. So far, I think this is a magic thing. If we use a classic comment, we can conclude that it is not difficult for a person to make a wrong choice question. What is difficult is to make all the mistakes wrong or wrong.
Unfortunately, this kind of small probability event happened again, and it was around us:
This is the case -- HDU has a male student named 8006, who has made countless friends. Recently, this student played a romantic game and wrote a letter to each of the N netizens. This is nothing, the worst thing is, he put all the messages in the wrong envelope! Note: It's all wrong!
The question is: How many possible error methods are there for the poor 8006 students?
The input data contains multiple test instances. Each test instance occupies one row and each row contains a positive integer of N (1 <n <= 20). N indicates the number of netizens of 8006.
Output: for each line of input, please output the number of possible error methods. The output of each instance occupies one line.
Sample Input
23
Sample output
12
Authorlcy
Sourceacm summer training team exercise (9)
Question: It's just a wrong Sorting Problem. Remember the wrong sorting formula and you can easily get through it ~! Knowledge point: the error formula: A [n] = (n-1) * (a [n-1] + A [N-2]); the Code is as follows:
#include<stdio.h>int main(){int n;__int64 a[22];a[2]=1;a[1]=0;for(int i=3;i<22;i++){a[i]=(i-1)*(a[i-1]+a[i-2]);//错排公式}while(~scanf("%d",&n)){printf("%I64d\n",a[n]);}return 0;}
HDU 1465 (not easily one of the series) (water problem, error row formula) (a [n] = (n-1) * (a [n-1] + A [N-2])