#P9825. [ICPC2020 Shanghai R] Fibonacci

[ICPC2020 Shanghai R] Fibonacci

题目描述

In mathematics, the Fibonacci numbers, commonly denoted as fnf_n, is a sequence such that each number is the sum of the two preceding numbers, starting with 11 and 11. That is, f1=1,f2=1f_1 = 1, f_2 = 1 and fn=fn2+fn1 (n3)f_n = f_{n-2} + f_{n-1}~(n \ge 3).

Thus, the beginning of the sequence is 1,1,2,3,5,8,13,21,1, 1, 2, 3, 5, 8, 13, 21,\ldots .

Given nn, please calculate i=1nj=i+1ng(fi,fj)\sum_{i=1}^{n}{\sum_{j=i+1}^{n}{g(f_i,f_j)}}, where g(x,y)=1g(x,y) = 1 when xyx \cdot y is even, otherwise g(x,y)=0g(x,y) = 0.

输入格式

The only line contains one integer n (1n109)n~(1\le n\le 10^9).

输出格式

Output one number -- i=1nj=i+1ng(fi,fj)\sum_{i=1}^{n}{\sum_{j=i+1}^{n}{g(f_i,f_j)}}.

题目大意

在数学中,斐波拉契数列常被记为数列 fnf_n。该数列的首项 f1,f2f_1,f_2 均为 11,并满足递推公式 fn=fn2+fn1(n3)f_n=f_{n-2}+f_{n-1}(n\ge 3)

因此,数列的前一些项为 1,1,2,3,5,8,13,21,1,1,2,3,5,8,13,21,\cdots

xyx\cdot y 为偶数,则函数 g(x,y)=1g(x,y)=1,否则 g(x,y)=0g(x,y)=0。求 $\sum\limits_{i=1}^n{\sum\limits_{j=i+1}^n{g(f_i,f_j)}}$ 的值。

3
2
10
24
100
2739