結果

問題 No.554 recurrence formula
ユーザー 6soukiti296soukiti29
提出日時 2017-08-11 23:15:56
言語 Nim
(2.0.2)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 396 bytes
コンパイル時間 2,804 ms
コンパイル使用メモリ 68,496 KB
実行使用メモリ 5,348 KB
最終ジャッジ日時 2023-09-12 14:03:47
合計ジャッジ時間 3,949 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,556 KB
testcase_01 AC 3 ms
4,504 KB
testcase_02 AC 3 ms
4,544 KB
testcase_03 AC 4 ms
4,528 KB
testcase_04 AC 3 ms
4,520 KB
testcase_05 AC 3 ms
4,560 KB
testcase_06 AC 4 ms
4,660 KB
testcase_07 AC 3 ms
4,692 KB
testcase_08 AC 3 ms
4,596 KB
testcase_09 AC 3 ms
4,552 KB
testcase_10 AC 3 ms
4,708 KB
testcase_11 AC 3 ms
4,572 KB
testcase_12 AC 3 ms
4,728 KB
testcase_13 AC 3 ms
4,720 KB
testcase_14 AC 4 ms
4,672 KB
testcase_15 AC 4 ms
4,608 KB
testcase_16 AC 4 ms
4,728 KB
testcase_17 AC 3 ms
4,552 KB
testcase_18 AC 3 ms
4,612 KB
testcase_19 AC 7 ms
5,348 KB
testcase_20 AC 7 ms
5,296 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import sequtils,strutils
var
    N = stdin.readline.parseInt
    A : array[100_010,int64]
    Sodd = A
    Seven = A
    m : int64 = (1e9).int + 7
A[1] = 1
Sodd[1] = 1
for n in 2..N:
    if (n and 1) == 1:
        A[n] = (Seven[n - 1] * n) mod m
        Sodd[n] = (Sodd[n - 2] + A[n]) mod m
    else:
        A[n] = (Sodd[n - 1] * n) mod m
        Seven[n] = (Seven[n - 2] + A[n]) mod m
echo A[N]
0