/* yukicoder No.53(Ver2) 作成者:ヒロソフ */ #include #include using namespace std; double Calc(int k); double Cache[98]; bool bWroteCache[98]; int main(void) { int N; for (int i = 0; i < 98; i++) { Cache[i] = 0; bWroteCache[i] = false; } scanf("%d", &N); cout << Calc(N) << endl; return 0; } double Calc(int k) { if (k == 0) { return 4; } else if (k == 1) { return 3; } else { if (bWroteCache[k - 2]) return Cache[k - 2]; Cache[k - 2] = (19.0 * Calc(k - 1) - 12.0 * Calc(k - 2)) / 4.0; bWroteCache[k - 2] = true; return Cache[k - 2]; } }