結果

問題 No.53 悪の漸化式
ユーザー codershifthcodershifth
提出日時 2015-07-27 21:32:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 947 bytes
コンパイル時間 1,181 ms
コンパイル使用メモリ 146,648 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-23 04:04:34
合計ジャッジ時間 2,098 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;


class EvilRecursion {
public:
    void solve(void) {
            int N;
            cin>>N;
            if (N == 0)
            {
                cout<<4<<endl;
                return;
            }
            if (N == 1)
            {
                cout<<3<<endl;
                return;
            }
            vector<long double> dp(N+1,0);
            dp[0] = 4.0;
            dp[1] = 3.0;
            FOR(i, 2, N+1)
                dp[i] = 4.75 *dp[i-1] - 3*dp[i-2];
            cout<<setprecision(20)<<dp[N]<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new EvilRecursion();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0