Submission #89897

# Submission time Handle Problem Language Result Execution time Memory
89897 2018-12-18T22:13:00 Z xiaowuc1 괄호 (kriii4_R) C++14
0 / 100
26 ms 19576 KB
#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 time Memory Grader output
1 Incorrect 26 ms 19576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 19576 KB Output isn't correct
2 Halted 0 ms 0 KB -