错排问题
#include<bits/stdc++.h> typedef long long LL; using namespace std; int n; LL a[100]; int main () { cin >> n; //错排 a[0] = 1; a[1] = 0; for(int i = 2;i <= n;++ i) { a[i] = (i - 1) * (a[i - 1] + a[i - 2]); } cout << a[n]; return 0; }
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 追梦算法网 universal account