問題一覧 > 通常問題

No.658 Tetranacci Sequence Hard

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 195
作問者 : ミドリムシ / テスター : ciel
お気に入りにしたユーザー ProblemId : 1973 / 自分の提出
問題文最終更新日: 2026-06-25 16:29:44
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 $n+1$ lines.
The first line contains an integer $Q(1 \leq Q \leq 10^4)$ representing the number of queries.
The $i+1(1 \leq i \leq Q)$-th line contains an integer $n_i(1 \leq n_i \leq 10^{18})$
.

Output

Output $Q$ lines.
On the $i(1 \leq i \leq Q)$-th line, 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 the remainders when divided by 17 are 0 and 12, respectively.

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
7
99
9999
999999
99999999
9999999999
999999999999
99999999999999
Output
12
16
14
13
6
16
9

The input values may not fit in a 32-bit integer.

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