No.554 recurrence formula
問題文最終更新日: 2026-06-26 06:07:39
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 171
(順位表)
の他の問題:
Problem Statement
Find the n-th term of the sequence {a} defined by the following recurrence, modulo $10^9+7$.
$a_1=1$
When n is not 1:
if n is even, $a_n=n*(a_1+a_3+a_5+・・・+a_{n-1})$
if n is odd, $a_n=n*(a_2+a_4+a_6+・・・+a_{n-1})$
Input
n
$ 1 \le n \le 10^5 $
Output
Output the n-th term of the sequence {a} modulo $10^9+7$. Print a newline at the end.
Sample
Sample 1
Input
2
Output
2
$a_2 = 2 * a_1 = 2$
Sample 2
Input
4
Output
28
$a_4 = 4 * (a_1 + a_3) = 28$
Sample 3
Input
6
Output
942
$a_6 = 6 * (a_1 + a_3 + a_5) = 942$
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
addeight2