Submission #19714

#TimeUsernameProblemLanguageResultExecution timeMemory
19714willbelucky괄호 (kriii4_R)C++98
0 / 100
8 ms1716 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...