問題一覧 > 通常問題

No.657 Tetranacci Sequence Easy

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 304
作問者 : ミドリムシ / テスター : ciel
お気に入りにしたユーザー ProblemId : 1971 / 自分の提出
問題文最終更新日: 2020-03-02 01:18:54
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 185 (順位表) の他の問題:

Problem Statement

There is a sequence called the Tetranacci sequence.
The Tetranacci sequence (denoted here by {$T_n$}) is defined as follows.
・$T_1 = 0,$ $T_2 = 0,$ $T_3 = 0,$ $T_4 = 1$
・$T_k = T_{k-1}$ $+$ $T_{k-2}$ $+$ $T_{k-3}$ $+$ $T_{k-4}$

Find the remainder when the $n_i$-th term $T_{n_i}$ of the Tetranacci sequence is divided by 17.

Input

$Q$
$n_1$
$n_2$

:

$n_Q$

The input consists of $Q+1$ lines.
The first line contains an integer $Q(1 \leq Q \leq 10^4)$, the number of queries.
Line $i+1(1 \leq i \leq Q)$ contains an integer $n_i(1 \leq n_i \leq 10^6)$.

Output

Output $Q$ lines.
On line $i(1 \leq i \leq Q)$, output the remainder when the $n_i$-th term $T_{n_i}$ of the Tetranacci sequence is divided by 17.
Add a newline at the end.

Sample

Sample 1
Input
2
3
10
Output
0
12

The 3rd term of the Tetranacci sequence is 0, and the 10th term is 29, so its remainder when divided by 17 is 12.

Sample 2
Input
6
3
2
1
3
1
4
Output
0
0
0
0
0
1

The input values are not necessarily all distinct.

Sample 3
Input
6
9
99
999
9999
99999
999999
Output
15
12
2
16
4
14

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。