제출 #1279110

#제출 시각아이디문제언어결과실행 시간메모리
1279110dostsAsceticism (JOI18_asceticism)C++20
49 / 100
169 ms327680 KiB
#include <bits/stdc++.h> #define int long long #define pii pair<int,int> #define vi vector<int> #define ff first #define ss second #define sp << " " << #define all(x) x.begin(),x.end() #define big(x) ((int)(x.size())) using namespace std; const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9; const int N = 1e5+1; int add(int x,int y) { if ((x + y) >= MOD) return x + y - MOD; return x + y; } int mult(int x,int y) { return (1LL * x * y) % MOD; } int expo(int x,int y) { if (!y) return 1; int e = expo(x, y >> 1); e = mult(e, e); if (y & 1) e = mult(e, x); return e; } void solve() { int n,k; cin >> n >> k; k--; int dp[n+1][n+1]{}; dp[0][0] = 1; for (int i = 1;i<=n;i++) { for (int j = 0;j<=i;j++) { if(j)dp[i][j] = add(mult(dp[i-1][j],(j+1)),mult(dp[i-1][j-1],(i-j))); else dp[i][j] = 1; } } cout << dp[n][k] << '\n'; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef Dodi freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif int t = 1; //cin >> t; while (t --> 0) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...