UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207382#3739. 球盒问题Soulmate10095ms137816kbC++11784b2024-07-28 18:36:122024-07-28 20:20:53

answer

#include <bits/stdc++.h>
using namespace std;
const int MOD=998244353;

int f(int n,int m) 
{

    vector<vector<long long>> dp(n+1,vector<long long>(m+1,0));

    
    for (int i=0;i<=n;i++) 
    {
        dp[i][0]=0;
    }
    for (int j=0;j<=m;j++) 
    {
        dp[0][j]=0;
    }
    for (int i=1;i<=n;i++) 
    {
        dp[i][1]=1;
    }
    for (int j=1;j<=m;j++) 
    {
        dp[j][j]=1;
    }

    
    for (int i=1;i<=n;i++)
    {


        for (int j=1;j<=m;j++) 
        {
            if (i>j) 
            {
                dp[i][j]=(dp[i-1][j-1]+j*dp[i-1][j]%MOD)%MOD;
            }
        }
    }

    return dp[n][m];
}

int main() 
{
    int n,m;
    cin>>n>>m;

    
    cout<<f(n,m)<<endl;

    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

5 3

output:

25

result:

ok 1 number(s): "25"

Test #2:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

8 6

output:

266

result:

ok 1 number(s): "266"

Test #3:

score: 10
Accepted
time: 0ms
memory: 1316kb

input:

92 83

output:

396151882

result:

ok 1 number(s): "396151882"

Test #4:

score: 10
Accepted
time: 0ms
memory: 1296kb

input:

74 70

output:

231315552

result:

ok 1 number(s): "231315552"

Test #5:

score: 10
Accepted
time: 0ms
memory: 2116kb

input:

465 284

output:

189220244

result:

ok 1 number(s): "189220244"

Test #6:

score: 10
Accepted
time: 0ms
memory: 2380kb

input:

474 350

output:

503314172

result:

ok 1 number(s): "503314172"

Test #7:

score: 10
Accepted
time: 0ms
memory: 2120kb

input:

438 298

output:

691903761

result:

ok 1 number(s): "691903761"

Test #8:

score: 10
Accepted
time: 35ms
memory: 103760kb

input:

3947 3327

output:

92333806

result:

ok 1 number(s): "92333806"

Test #9:

score: 10
Accepted
time: 22ms
memory: 63632kb

input:

2966 2692

output:

291036270

result:

ok 1 number(s): "291036270"

Test #10:

score: 10
Accepted
time: 38ms
memory: 137816kb

input:

4313 4052

output:

74515633

result:

ok 1 number(s): "74515633"