제출 #226200

#제출 시각아이디문제언어결과실행 시간메모리
226200DS007Asceticism (JOI18_asceticism)C++14
49 / 100
1102 ms98552 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mod = 1e9 + 7;
map<pair<int, int>, int> dp;
int n, k;

int calc(int i, int j) {
    if (i < j || j == 0)
        return 0;
    else if (dp[{i, j}])
        return dp[{i, j}];
    else if (i == j)
        return dp[{i, j}] = 1;
    return dp[{i, j}] = (j * calc(i - 1, j) + (i - j + 1) * calc(i - 1, j - 1)) % mod;
}

void solveTestCase() {
    cin >> n >> k;
    cout << calc(n, k);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int test = 1;
    // cin >> test;
    for (int i = 1; i <= test; i++)
        solveTestCase();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...