結果
| 問題 |
No.53 悪の漸化式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-01 14:32:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 122 ms / 5,000 ms |
| コード長 | 307 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 82,536 KB |
| 実行使用メモリ | 80,352 KB |
| 最終ジャッジ日時 | 2024-10-10 04:16:19 |
| 合計ジャッジ時間 | 3,410 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
import decimal
import math
N = int(input())
A = [4,3]
B = [1,1]
for i in range(2,N+1):
a0,b0 = A[i-2],B[i-2]
a1,b1 = A[i-1],B[i-1]
x = 19*a1*b0 - 12*a0*b1
y = b0 * b1 * 4
g = math.gcd(x,y)
x //= g
y //= g
A.append(x)
B.append(y)
print(decimal.Decimal(A[N]/B[N]))