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 <cstdio>
#include <cstring>
#include <vector>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef vector < int > vi;
const int N = 3e3 + 50;
const int MOD = 1e9 + 7;
inline int add(int A,int B){
if(A + B >= MOD) return A + B - MOD;
return A + B;
}
inline int mul(int A,int B){
return (ll)A * B % MOD;
}
inline int sub(int A,int B){
if(A - B < 0) return A - B + MOD;
return A - B;
}
int dp[N][N], n, k;
int f(int x,int y){
if(x == n) return (y + 1 == k);
if(dp[x][y] != -1) return dp[x][y];
return dp[x][y] = add(mul(y + 1, f(x + 1, y)), mul(x - y, f(x + 1, y + 1)));
}
int main(){
memset(dp, -1, sizeof(dp));
scanf("%d%d", &n, &k);
printf("%d\n", f(1, 0));
return 0;
}
Compilation message (stderr)
asceticism.cpp: In function 'int main()':
asceticism.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &k);
~~~~~^~~~~~~~~~~~~~~~
# | 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... |