G - Fibonacci(2020 ICPC Asia Shanghai Regional Contest)

In mathematics, the Fibonacci numbers, commonly denoted as fn, is a sequence such that each number is the sum of the two preceding numbers, starting with 1 and 1. That is, f1=1,f2=1 and fn=fn−2+fn−1 (n≥3).

Thus, the beginning of the sequence is 1,1,2,3,5,8,13,21,…

Given n, please calculate ∑ni=1∑nj=i+1g(fi,fj), where g(x,y)=1 when x⋅y is even, otherwise g(x,y)=0.

Input
The only line contains one integer n (1≤n≤109).

Output
Output one number – ∑ni=1∑nj=i+1g(fi,fj).

Examples

Input

3

Output

2

Input

10

Output

24

Input

100

Output

2739
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    scanf("%lld",&n);
    ll m=((n-1)*n)/2;
    ll k=n/3*2;
    if(n%3==1)
        k+=1;
    if(n%3==2)
        k+=2;
     k=((k-1)*k)/2;
    cout<<m-k<<endl;
    return 0;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值