結果

問題 No.53 悪の漸化式
コンテスト
ユーザー sue_charo
提出日時 2017-05-21 18:51:21
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 116 ms / 5,000 ms
+ 58µs
コード長 756 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 281 ms
コンパイル使用メモリ 21,340 KB
実行使用メモリ 16,556 KB
最終ジャッジ日時 2026-08-30 22:27:49
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
from decimal import *
getcontext().prec = 100
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N = II()
    return N


def solve(N):
    dp = [Decimal(0)] * 101
    dp[0] = Decimal(4)
    dp[1] = Decimal(3)
    for i in range(2, N + 1):
        dp[i] = (19 * dp[i - 1] - 12 * dp[i - 2]) / 4

    ans = dp[N]

    return ans


def main():
    params = read()
    print(solve(params))


if __name__ == "__main__":
    main()
0