如果将两种方案中每个农夫都购买了相同的奶牛看作是相同的销售方案。那么农夫 John 一共有多少种不同的销售方案呢?
3
1
2
3
0
1
6
对于50%的数据,N≤20,
对于100%的数据,N≤2000.
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod=1e7+7; ll f[2005]; void init() { f[2]=1; for(ll i=3;i<=2000;i++) { f[i]=(i*(i-1)*f[i-1]%mod+i*(i-1)/2*(i-1)*f[i-2]%mod)%mod; } } int main() { init(); int t;cin>>t; while(t--) { int x; scanf("%d",&x); cout<<f[x]<<endl; } return 0; }
原文:https://www.cnblogs.com/Suiyue-Li/p/11172941.html