結果

問題 No.554 recurrence formula
コンテスト
ユーザー No-Ra
提出日時 2017-08-11 23:35:42
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 868 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 57 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 34,944 KB
最終ジャッジ日時 2026-09-15 03:49:53
合計ジャッジ時間 11,598 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 TLE * 2 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
import sys
# intMaxOver2 = 2147483647 * 100000000000000

n = int(input())
solvememo = [0 for i in range(100001)]


def solve(n):
    if n == 1:
        return 1
    else:
        if n % 2 == 0:
            if solvememo[n] != 0:
                return solvememo[n]
            else:
                sum = 0
                i = 1
                while i < n:
                    sum += solve(i)
                    i = i + 2
                solvememo[n] = n * sum
                return solvememo[n]
        else:
            if solvememo[n] != 0:
                return solvememo[n]
            else:
                sum = 0
                i = 2
                while i < n:
                    sum += solve(i)
                    i = i + 2
                solvememo[n] = n * sum
                return solvememo[n]

ans = solve(n)
print(ans % 1000000007)
0