이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |