제출 #1004063

#제출 시각아이디문제언어결과실행 시간메모리
1004063ef10캥거루 (CEOI16_kangaroo)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; typedef long long ll; int n, a, b; inline int add(int a, int b) { if(!b) return a; int x = a+b; if(x >= mod) x -= mod; else if(x < 0) x += mod; return x; } ll mul(ll a, ll b) { return (a * b) % mod; } ll dp[2002][2002]; int main() { std::ifstream input; input.open("kangaroo.in"); std::ofstream output; output.open("kangaroo.out"); input >> n >> a >> b; dp[1][1] = 1; for(int i = 2; i <= n; ++i) for(int j = 1; j <= n; ++j) { if(i == a || i == b) dp[i][j] = add(dp[i-1][j-1], dp[i-1][j]); else dp[i][j] = add(mul(dp[i-1][j+1], j), mul(dp[i-1][j-1], j - (i > a) - (i > b))); } output << dp[n][1]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...