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 <iostream>
using namespace std;
int main()
{
for (int cases = 0; cases < 3; cases++)
{
int N, K;
cin >> N >> K;
int cache[4];
cache[0] = 1;
cache[1] = K;
for (int iter = 2; iter < N+1; iter++)
{
cache[iter&3] = ((cache[(iter - 2)&3] + cache[(iter - 1)&3])*K % 1000000007);
}
cout << cache[N&3] << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |