1 solutions

  • 0
    @ 2024-10-15 14:53:05

    错排问题

    #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;
    }
    
    
    • 1

    Information

    ID
    1031
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    3
    Tags
    # Submissions
    52
    Accepted
    28
    Uploaded By