結果
| 問題 | No.314 ケンケンパ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-07 02:02:50 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 763 bytes |
| 記録 | |
| コンパイル時間 | 165 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 29,000 KB |
| 最終ジャッジ日時 | 2024-09-14 17:52:40 |
| 合計ジャッジ時間 | 4,614 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 16 |
コンパイルメッセージ
Syntax OK
ソースコード
#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU
# last
# ケン
# ケンケン
# ケンパ
# ケンケンパ
# interval
# ケンパ
# ケンケンパ
# n = 1
# ケン
# n = 2
# ケンケン
# ケンパ
# n = 3
# ケンパケン
# ケンケンパ
# n = 4
# ケンパケンパ
# ケンパケンケン
# ケンケンパケン
n = gets.to_i
MD = (10 ** 9) + 7
def cmb(n, c)
r = 1
c = [c, n - c].min
c.times do |i|
r *= n - i
r /= (i + 1)
end
r % MD
end
def fnc(n)
c = 0
i = 0
while n >= 0 do
d, m = n.divmod 2
if m == 0
c = (c + cmb(d + i, i)) % MD
end
i += 1
n -= 3
end
c
end
c = fnc(n) + fnc(n - 1) + fnc(n - 2)
puts (c % MD)