제출 #19842

#제출 시각아이디문제언어결과실행 시간메모리
19842willbelucky괄호 (kriii4_R)C++98
0 / 100
0 ms1716 KiB
#include <iostream>
using namespace std;

int main()
{
	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;

	cout << cache[N & 3] % 1000000007 << endl;

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...