yukicoder No.53 悪の漸化式
問題概要
漸化式で表されている数列の第n項を求める問題。
解法
3項間漸化式を解いて、一般項を求めた。一般項は
a(k) = 4*(3/4)k (k >= 0)
となるので、これを利用した。
ミス
高校数学忘れるね。
コード
#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main(void){ double n; cin >> n; //3項間漸化式を解いて、一般項を求めた double ans = 4 * pow(3.0 / 4.0, n); printf("%.10f\n", ans); return 0; }