結果

問題 No.53 悪の漸化式
ユーザー lloyzlloyz
提出日時 2022-08-10 01:54:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 11,980 KB
実行使用メモリ 10,740 KB
最終ジャッジ日時 2023-10-20 11:19:36
合計ジャッジ時間 1,618 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
10,732 KB
testcase_01 AC 32 ms
10,732 KB
testcase_02 AC 32 ms
10,732 KB
testcase_03 AC 32 ms
10,732 KB
testcase_04 AC 31 ms
10,732 KB
testcase_05 AC 32 ms
10,732 KB
testcase_06 AC 32 ms
10,732 KB
testcase_07 AC 32 ms
10,732 KB
testcase_08 AC 33 ms
10,732 KB
testcase_09 AC 32 ms
10,732 KB
testcase_10 AC 32 ms
10,732 KB
testcase_11 AC 32 ms
10,732 KB
testcase_12 AC 32 ms
10,732 KB
testcase_13 AC 33 ms
10,732 KB
testcase_14 AC 32 ms
10,732 KB
testcase_15 AC 33 ms
10,736 KB
testcase_16 AC 33 ms
10,736 KB
testcase_17 AC 33 ms
10,736 KB
testcase_18 AC 33 ms
10,736 KB
testcase_19 AC 34 ms
10,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
import sys

if len(sys.argv) == 2:
    sys.stdin = open(sys.argv[1])

n = int(input())
A = [0 for _ in range(n + 1)]

if n == 0:
    print(4.0)
    exit()
if n == 1:
    print(3.0)
    exit()

A[0] = Fraction(4)
A[1] = Fraction(3)
for i in range(2, n + 1):
    A[i] = Fraction(19, 4) * A[i - 1] - 3 * A[i - 2]
print(f"{float(A[n]):.20f}")
0