Submission #1236295

#TimeUsernameProblemLanguageResultExecution timeMemory
1236295AmirAli_H1Asceticism (JOI18_asceticism)C++20
49 / 100
40 ms46916 KiB
// In the name of Allah #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<ld> cld; #define all(x) (x).begin(),(x).end() #define len(x) ((ll) (x).size()) #define F first #define S second #define pb push_back #define sep ' ' #define endl '\n' #define Mp make_pair #define kill(x) cout << x << '\n', exit(0) #define set_dec(x) cout << fixed << setprecision(x); #define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 3000 + 4; const int mod = 1e9 + 7; int n, k; ll dp[maxn][maxn]; void solve() { cin >> n >> k; k--; dp[1][0] = 1; for (int i = 1; i < n; i++) { for (int j = 0; j < i; j++) { (dp[i + 1][j] += dp[i][j] * (j + 1)) %= mod; (dp[i + 1][j + 1] += dp[i][j] * (i - j)) %= mod; } } cout << dp[n][k] << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T = 1; while (T--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...