4个RE或者10个RE
查看原帖
4个RE或者10个RE
49677
miserExist楼主2021/7/8 09:25

RE1个小时了

数组开500 * 500 4个RE

开2000 * 2000 20个RE

#include <bits/stdc++.h>
using namespace std;

//#define int long long


int C[2012][2012];
int st[2012][2012];
signed main()
{
    //n > m
    int t,k;
    cin >> t >> k;
    // C n m    m > 
    //C[0][0] = C[1][0] = 1;
    for(int i = 0; i <= 2012; i ++)
    {
        for(int j = 0; j <= i; j ++)
        {
            
            if(!j)C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % k;
            if(C[i][j] == 0)st[i][j] = 1;
            st[i][j] += st[i - 1][min(j,i - 1)] + st[i][j - 1] - st[i - 1][j - 1]; //auto add 1
        }
        //st[i][i + 1] = st[i][i];
    }

    /*for( int i = 1; i <= N; i ++ )
    {
        for(int j = 1; j <= N; j ++)
        {
            
        }
    }*/
    /*for(int i = 1; i <= 20; i ++)
    {
        for(int j = 1; j <= 20; j ++)
        {
            cout << st[i][j] << " ";
        }
        cout << endl;
    }*/

    while(t --)
    {
        int n,m;
        cin >> n >> m; 
        if(m > n)cout << st[n][n] << endl;
        else cout << st[n][m] << endl;
    }


    return 0;
}
`cpp
2021/7/8 09:25
加载中...