#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1000000007;
ll dp[2000005];
ll solve(int n, int k) {
if(n == 0) return 1;
if(n == 2) return k;
if(dp[n]) return dp[n];
// (s)
ll ret = k*solve(n-2, k);
ret %= MOD;
// ()s()
if(n >= 4) {
ret += k*solve(n-4, k);
ret %= MOD;
}
dp[n] = ret;
return ret;
}
void solve() {
int n, k;
cin >> n >> k;
cout << solve(2*n, k) << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
19320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
19320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |