一锐是天梯赛的忠实粉丝,表现也越来越好,几乎每场都能领到红包,很开心,要知道他才四年级哈。
下面这道题,相信一锐能做出来,其他同学也应该能轻松AC, Good Luck!
给定一个正整数n,根据下面这个式子计算f(n)的值:
For a positive integer n let's define a function f:
Your task is to calculate f(n) for a given integer n.
一锐是天梯赛的忠实粉丝,表现也越来越好,几乎每场都能领到红包,很开心,要知道他才四年级哈。
下面这道题,相信一锐能做出来,其他同学也应该能轻松AC, Good Luck!
给定一个正整数n,根据下面这个式子计算f(n)的值:
For a positive integer n let's define a function f:
Your task is to calculate f(n) for a given integer n.
输入n, 1<=n<=10^15
The single line contains the positive integer n (1 ≤ n ≤ 10^15).
输出f(n)的值
Print f(n) in a single line.
4
2
样例2输入
5
样例2输出
-3
f(4) = - 1 + 2 - 3 + 4 = 2
f(5) = - 1 + 2 - 3 + 4 - 5 = - 3