이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LD long double
const int N = 100010;
int inf = 1e9;
int mod = 1e9 + 7;
inline void add(int &a, int b) {
a += b;
if (a >= mod) a -= mod;
}
inline void sub(int &a, int b) {
a -= b;
if (a < 0) a += mod;
}
inline int mul(int a, int b) {
return (int) ((long long) a * b % mod);
}
inline int power(int a, long long b) {
int res = 1;
while (b > 0) {
if (b & 1) {
res = mul(res, a);
}
a = mul(a, a);
b >>= 1;
}
return res;
}
inline int inv(int a) {
a %= mod;
if (a < 0) a += mod;
int b = mod, u = 0, v = 1;
while (a) {
int t = b / a;
b -= t * a; swap(a, b);
u -= t * v; swap(u, v);
}
assert(b == 1);
if (u < 0) u += mod;
return u;
}
signed main()
{
freopen("kangaroo.in", "r", stdin);
freopen("kangaroo.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
int cs, cf;
cin >> cs >> cf;
int dp[n + 1][n + 2];
memset(dp, 0, sizeof(dp));
dp[1][1] = 1;
for (int i = 2; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (i == cs || i == cf) {
add(dp[i][j], dp[i - 1][j - 1]);
add(dp[i][j], dp[i - 1][j]);
continue;
}
add(dp[i][j], mul(j, dp[i - 1][j + 1]));
int ins = j;
if (i > cs) sub(ins, 1);
if (i > cf) sub(ins, 1);
add(dp[i][j], mul(ins, dp[i - 1][j - 1]));
}
}
cout << dp[n][1] << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
kangaroo.cpp: In function 'int main()':
kangaroo.cpp:55:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
55 | freopen("kangaroo.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:56:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
56 | freopen("kangaroo.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |