結果

問題 No.2600 Avator Height
ユーザー ThetaTheta
提出日時 2024-02-02 19:36:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 890 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 217,524 KB
最終ジャッジ日時 2024-02-02 19:37:05
合計ジャッジ時間 53,128 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 529 ms
205,568 KB
testcase_01 AC 1,999 ms
208,836 KB
testcase_02 AC 1,994 ms
182,320 KB
testcase_03 AC 1,979 ms
173,032 KB
testcase_04 AC 1,932 ms
167,152 KB
testcase_05 AC 1,925 ms
142,704 KB
testcase_06 AC 1,948 ms
155,908 KB
testcase_07 AC 1,903 ms
163,752 KB
testcase_08 AC 1,953 ms
180,944 KB
testcase_09 AC 1,918 ms
184,496 KB
testcase_10 AC 1,957 ms
184,848 KB
testcase_11 AC 1,923 ms
148,448 KB
testcase_12 AC 1,984 ms
205,384 KB
testcase_13 AC 1,976 ms
177,964 KB
testcase_14 AC 1,983 ms
164,460 KB
testcase_15 AC 1,990 ms
156,064 KB
testcase_16 AC 1,998 ms
174,760 KB
testcase_17 AC 1,944 ms
144,300 KB
testcase_18 AC 1,985 ms
138,384 KB
testcase_19 AC 1,941 ms
155,256 KB
testcase_20 AC 1,954 ms
144,388 KB
testcase_21 TLE -
testcase_22 AC 1,979 ms
173,220 KB
testcase_23 TLE -
testcase_24 AC 1,001 ms
9,984 KB
testcase_25 AC 1,572 ms
205,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import cache
import sys

sys.setrecursionlimit(10000000)


@cache
def fibonacci(N: int) -> int:
    if N in (1, 2):
        return 1
    return fibonacci(N - 2) + fibonacci(N - 1)


@cache
def fibonacci_mod(N: int, mod: int) -> int:
    if N in (1, 2):
        return 1
    return (fibonacci_mod(N - 2, mod) + fibonacci_mod(N - 1, mod)) % mod


@cache
def nacci_r(N: int, mod: int) -> int:
    return fibonacci_mod(N, mod)


@cache
def nacci_e(N: int, mod: int) -> int:
    if N == 1:
        return 1
    if N == 2:
        return 3
    return (nacci_e(N - 1, mod) + nacci_e(N - 2, mod)) % mod


def calc_width_diff(N: int) -> int:
    MOD = 998244353
    return ((5 * nacci_r(N, MOD) ** 2) % MOD - nacci_e(N, MOD) ** 2) % MOD


def main():
    for _ in range(int(input())):
        N = int(input())
        print(calc_width_diff(N))


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