結果

問題 No.336 門松列列
ユーザー finefine
提出日時 2016-01-17 02:06:18
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 422 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 11,984 KB
実行使用メモリ 819,144 KB
最終ジャッジ日時 2023-10-20 00:26:27
合計ジャッジ時間 15,302 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
if n < 3
    puts 0
    exit
end
t = Array.new(n)
n.times{|i|
    t[i] = Array.new(i+1)
    }
t[0][0] = 1
1.upto(n-1){|i|
    if i % 2 == 1
        t[i][0] = 0
        1.upto(i){|j|
            t[i][j] = t[i][j-1] + t[i-1][j-1]
            }
    else
        t[i][i] = 0
        (i-1).downto(0){|j|
            t[i][j] = t[i][j+1] + t[i-1][j]
            }
    end
    }
p t[n-1].inject(&:+) * 2 % 1000000007
0