이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <climits>
#include <cmath>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <unordered_map>
#define ll long long
#define ull unsigned long long
#define unit unsigned int
#define ld double
#define F first
#define S second
// chrono::system_clock::now().time_since_epoch().count());
using namespace std;
const int N = 2e3 + 10, IINF = 1e7, LOG = 19, K = 73;
const ll M = 1e9 + 7, INF = 1e14 + 214;
int pls(int a, int b){
a += b;
while(a >= M)
a -= M;
while(a <= 0)
a += M;
return a;
}
int mult(int a, int b){
return 1ll * a * b % M;
}
int dp[N][N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
int n, a, b;
cin >> n >> a >> b;
dp[1][1] = 1;
for (int i = 2; i <= n; i ++){
for (int j = 1; j <= n; j ++){
if (a == i || b == i)
dp[i][j] = pls(dp[i - 1][j - 1], dp[i - 1][j]);
else {
int f1 = mult(dp[i - 1][j + 1], j);
int f2 = mult(dp[i - 1][j - 1], j);
dp[i][j] = pls(f1, f2);
}
}
}
cout << dp[n][1];
return 0;
}
# | 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... |