Submission #89897

#TimeUsernameProblemLanguageResultExecution timeMemory
89897xiaowuc1괄호 (kriii4_R)C++14
0 / 100
26 ms19576 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MOD = 1000000007; ll dp[1000005]; 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(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...