Calculations

0

0 votes
Integer Factorization, Basics of Implementation, Implementation, Mathematics, Math, Number Theory
Problem

You are given the following recurrent formula:

Tn=Tn1+Tn2+Tn3 , at n>3, T1=3,T2=2,T3=1

Calculate the following value, S=(T21+T22+...+T2N)mod(109+7).

Input format

The first line contains one integer N.

Output format

Print S denoting the answer to the problem.

Constraints

1N1018

 

Sample Input
8
Sample Output
4484
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

t[1] = 3

t[2] = 2

t[3] = 1

t[4] = 6

t[5] = 9

t[6] = 16

t[7] = 31

t[8] = 56

S = (3^2+2^2+1^2+6^2+9^2+16^2+31^2+56^2) mod (1e9+7)=4484

Editor Image

?