Hdu 4535 吉哥系列故事——礼尚往来
2013-03-30 22:13
225 查看
题目连接:
http://acm.hdu.edu.cn/showproblem.php?pid=4535
错排公式:
代码:
http://acm.hdu.edu.cn/showproblem.php?pid=4535
错排公式:
f(n)=(n-1)(f(n-1)+f(n-2))
代码:
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <vector> #include <algorithm> using namespace std; #define MAXN (100+10) __int64 f[MAXN]={0,0,1}; __int64 h = 1000000007; int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int t; int n; for (int i=3;i<=100;i++) { f[i]=((i-1)*f[i-1]%h+f[i-2]*(i-1)%h)%h; } scanf(" %d",&t); while (t--) { scanf(" %d",&n); printf("%I64d\n",f ); } }
相关文章推荐
- hdu 4535 吉哥系列故事——礼尚往来
- HDU-4535-吉哥系列故事——礼尚往来
- hdu 4535 吉哥系列故事——礼尚往来
- hdu-4535-吉哥系列故事——礼尚往来-组合数学-错排-java
- hdu 4535 吉哥系列故事——礼尚往来
- HDU 4535 吉哥系列故事——礼尚往来(错排)
- HDU 4535 吉哥系列故事——礼尚往来(水题,错排)
- HDU 4535 吉哥系列故事——礼尚往来( 错排问题)
- HDU 4535 吉哥系列故事——礼尚往来
- 杭电4535吉哥系列故事——礼尚往来
- HDU_4535 吉哥系列故事——礼尚往来
- HDU 4535 吉哥系列故事——礼尚往来
- 吉哥系列故事——礼尚往来(4535)
- HDU 4535 吉哥系列故事——礼尚往来
- hdu 4535 吉哥系列故事——礼尚往来(错排)
- HDU:4535 吉哥系列故事——礼尚往来(数学:错排)
- 杭电4535-吉哥系列故事——礼尚往来
- hdu 4535 吉哥系列故事——礼尚往来
- hdoj-4535-吉哥系列故事——礼尚往来
- HDU-4507 吉哥系列故事――恨7不成妻 (数位dp)