#P4881. Palindrome String Game
Palindrome String Game
Palindrome String Game
You are given an integer n. Compute the answer defined by the formula below:
[ Ans = \sum_{i=1}^{n} i \times s[i] \times [i \bmod 2] ]
Here, for each i, s[i] denotes the number of palindromic strings of length i formed using only lowercase letters. Note that the boolean expression ([i \bmod 2]) evaluates to 1 if i is odd and 0 if i is even. In other words, only odd values of i contribute to the sum. In particular, for an odd i we have
[ s[i] = 26^{\frac{i+1}{2}}, ]
since a palindrome of odd length is completely determined by its first (\frac{i+1}{2}) characters. Due to the potentially huge answer, output it modulo (10^9+7).
Note: You must compute the answer within 1 second. Failure to do so might cause catastrophic consequences for hby and tkw’s relationship!
inputFormat
The input consists of a single integer n (1 ≤ n).
outputFormat
Output a single integer: the value of Ans modulo (10^9+7).
sample
1
26