This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int N, M;
long long cache[2000001];
long long solve(int pos)
{
if(pos > 2 * N)
return 0;
if(pos == 2 * N)
return 1;
long long& ans = cache[pos];
if(ans != -1)
return ans;
ans = (solve(pos + 2) * M) % MOD;
ans = (ans + solve(pos + 4) * M) % MOD;
return ans;
}
int main()
{
memset(cache, -1, sizeof(cache));
scanf("%d%d", &N, &M);
printf("%lld", solve(0));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |