A The stupid owls
时间限制:1000ms 内存限制:65536kb
题目描述
Bamboo recently bought an owl for sending and receiving letters. Every owl will bring a letter to exactly one person, so normally Bamboo's owl will only bring letters for her.
Although most owls sold in the magical stores are extremely conscientious almost all the time, sometimes they can also make mistakes. For example, on one occasion Bamboo's owl brought a letter to her roommate Eve, and Eve's owl brought a letter to Bamboo .The two stupid owls made mistakes at the same time!
What's worse, if there were n people, each with a stupid owl, so that every one might get a wrong letter . So what the probability of no one getting his or her correct letter?
输入
The input file will contain a list of positive integers n, one per line(0<n<25)。
输出
For each integer n in the input, output the probability(in percentage form) of the n people all receiving a letter that ought to be sent to another one.
Print each output in one line. Please keep two decimals.
输入样例
2
输出样例
50.00%
HINT
错排~
题目分析
示例代码
#include<cstdio>
long long d(long long n)
{if(n==1)return 0;if(n==2)return 1;elsereturn (n-1)*(d(n-1)+d(n-2));
}
int main()
{long long n;while(scanf("%lld",&n)!=EOF){double y=1;double x=d(n);for(int i=1;i<=n;i++){y=y*i;}printf("%.2lf%%\n",x/y*100);}
}