This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second
#define ld long double
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define int long long
#define PII pair<pii , pii>
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
#define deb(x) cout <<#x << " : " << x << "\n" ;
using namespace std ;
const int maxn = 3002 , mod = 1e9 + 7 , b = 56 , maxp = 15e5 + 10, inf= 1e9+10 , lg = 20;
int dp[maxn][maxn];
signed main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n , k ;
cin >> n >> k ;
dp[1][0] = 1;
rep(i , 1 , n){
rep(j , 0, k){
dp[i+1][j] = (dp[i][j]*(j+1) + dp[i+1][j])%mod ;
dp[i+1][j+1] = (dp[i][j] * (i-j) + dp[i+1][j+1])%mod ;
}
}
cout << dp[n][k-1] << '\n';
}
/*
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |