제출 #1306922

#제출 시각아이디문제언어결과실행 시간메모리
1306922Double_SlashAsceticism (JOI18_asceticism)C++20
49 / 100
1094 ms1016 KiB
#pragma GCC optimize("Ofast,unroll-loops,inline")
#include <bits/stdc++.h>
#pragma GCC target("avx2")

using namespace std;
using ll = long long;

const int M = 1e9 + 7;

int N, K;
ll dp[100000]{1}, dp2[100000]{1};

int main() {
    cin >> N >> K;
    for (int n = 1; n <= N;) {
        for (int k = n; k > 0; --k) {
            dp2[k] = (dp[k] * (k + 1) + dp[k - 1] * (n - k)) % M;
        }
        if (n++ == N) cout << dp2[K - 1];
        for (int k = n; k > 0; --k) {
            dp[k] = (dp2[k] * (k + 1) + dp2[k - 1] * (n - k)) % M;
        }
        if (n++ == N) cout << dp[K - 1];
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...