#P8377. [PFOI Round1] 暴龙的火锅
[PFOI Round1] 暴龙的火锅
Background
The T-Rex loves eating hotpot.
Problem Description
Define as the sum of the digits of . For example, , and
Also, define as the -th term of the Fibonacci sequence. Specifically:
$$fib(1)=fib(2)=1,\ fib(x)=fib(x-1)+fib(x-2)\ (x\ge 3).$$Given , compute the value of the following expression, where means taking the remainder modulo :
$$(S(fib(1))+S(fib(2))+S(fib(3))+...+S(fib(n))) \bmod 9.$$Input Format
The first line contains an integer .
Then follow queries, each containing one integer .
Output Format
Output lines, each line containing one integer representing the answer.
3
7
14
114514
6
5
8
Hint
[Sample Explanation]
For the first query, , the answer is:
$$\begin{aligned} & \ \ \ \ \ (S(fib(1))+S(fib(2))\ldots+S(fib(6))+S(fib(7)))\bmod 9 \\ & =(1+1+2+3+5+8+(1+3))\bmod 9 \\ & =6. \end{aligned}$$[Constraints]
This problem uses bundled testdata.
- ;
- ;
- no special constraints.
For of the data, .
Translated by ChatGPT 5