結果

問題 No.336 門松列列
ユーザー finefine
提出日時 2016-01-17 02:08:49
言語 Ruby
(3.3.0)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 11,284 KB
実行使用メモリ 31,144 KB
最終ジャッジ日時 2023-09-02 18:45:01
合計ジャッジ時間 3,867 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 319 ms
28,056 KB
testcase_01 AC 77 ms
15,132 KB
testcase_02 AC 79 ms
15,152 KB
testcase_03 AC 78 ms
15,308 KB
testcase_04 AC 380 ms
31,104 KB
testcase_05 AC 78 ms
15,328 KB
testcase_06 AC 111 ms
16,728 KB
testcase_07 AC 184 ms
20,764 KB
testcase_08 AC 275 ms
25,288 KB
testcase_09 AC 371 ms
30,492 KB
testcase_10 AC 383 ms
31,144 KB
testcase_11 AC 379 ms
31,084 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]) % 1000000007
            }
    else
        t[i][i] = 0
        (i-1).downto(0){|j|
            t[i][j] = (t[i][j+1] + t[i-1][j]) % 1000000007
            }
    end
    }
p t[n-1].inject(&:+) * 2 % 1000000007
0