#Q224. 「一本通 6.5 例 4」佳佳的 Fibonacci
「一本通 6.5 例 4」佳佳的 Fibonacci
Description
Jiajia is very interested in mathematics, especially in sequences. After studying the Fibonacci sequence, she has created many peculiar sequences. For example, let denote the sum of the first terms of the Fibonacci sequence modulo , i.e., , where and . However, this is still a piece of cake for Jiajia.
Finally, she encountered a problem she couldn't solve. Let represent the modified sum of the first terms of the Fibonacci sequence modulo .
Now, Jiajia gives you two integers and , and asks you to compute the value of .
Input Format
The input consists of a single line containing two integers and , separated by a space.
Output Format
Output a single line containing the value of .
Sample 1
$T(5)=(1+2\times 1+3\times 2+4\times 3+5\times 5)\bmod 5=1$
5 5
1
Constraints and Hints
For of the data, ;
For of the data, ;
For of the data, .