Problem description

For a positive integer n let's define a function f:

f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn

Your task is to calculate f(n) for a given integer n.

Input

The single line contains the positive integer n (1 ≤ n ≤ 1015).

Output

Print f(n) in a single line.

Examples

Input

4

Output

2

Input

5

Output

-3

Note

f(4) =  - 1 + 2 - 3 + 4 = 2

f(5) =  - 1 + 2 - 3 + 4 - 5 =  - 3

解题思路:简单求前n项和,分为奇数和偶数两种情况,水过!

AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
if(n&)cout<<(n/-n)<<endl;
else cout<<(n/)<<endl;
return ;
}

B - Calculating Function的更多相关文章

  1. Codeforces Round #277 (Div. 2) A. Calculating Function 水题

    A. Calculating Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/4 ...

  2. cf486A Calculating Function

    A. Calculating Function time limit per test 1 second memory limit per test 256 megabytes input stand ...

  3. Codeforces Round #277 (Div. 2)---A. Calculating Function (规律)

    Calculating Function time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #277 (Div. 2)A. Calculating Function 水

    A. Calculating Function   For a positive integer n let's define a function f: f(n) =  - 1 + 2 - 3 +  ...

  5. Codeforces Round #277(Div. 2) (A Calculating Function, B OR in Matrix, C Palindrome Transformation)

    #include<iostream> #include<cstring> #include<cstdio> /* 题意:计算f(n) = -1 + 2 -3 +4. ...

  6. codeforces水题100道 第十题 Codeforces Round #277 (Div. 2) A. Calculating Function (math)

    题目链接:www.codeforces.com/problemset/problem/486/A题意:求表达式f(n)的值.(f(n)的表述见题目)C++代码: #include <iostre ...

  7. Codeforces Round #277 (Div. 2) A B C 水 模拟 贪心

    A. Calculating Function time limit per test 1 second memory limit per test 256 megabytes input stand ...

  8. 套题 Codeforces Round #277 (Div. 2)

    A. Calculating Function 水题,分奇数偶数处理一下就好了 #include<stdio.h> #include<iostream> using names ...

  9. Codeforces Round #277 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/486 A题.Calculating Function 奇偶性判断,简单推导公式. #include<cstdio> ...

随机推荐

  1. Arduino 红外接收

    一.实物图 二.例子代码 注:git clone https://github.com/z3t0/Arduino-IRremote.git 放到Arduino 的libraries目录下面  从遥控器 ...

  2. openstack--memecache

    一.缓存系统 静态web页面: 1.工作流程: 在静态Web程序中,客户端使用Web浏览器(IE.FireFox等)经过网络(Network)连接到服务器上,使用HTTP协议发起一个请求(Reques ...

  3. js取最值:

    取最值是很常见的一种运算,各个语言都会遇到这个问题.Js中,如果简单的进行取最值,完全没必要自己写一个比较函数,原生的js就提供了方法.这些方法都属于Math 对象(引用w3c:Math 对象并不像 ...

  4. DFS-BFS深度优选遍历和广度优先遍历

    https://www.jianshu.com/p/b086986969e6 DFS--需要借助stack实现 stack.push stack.pop BFS--需要借助队列queue stack- ...

  5. appium的滑动

    #coding = utf-8from appium import webdriverimport time'''1.手机类型2.版本3.手机的唯一标识 deviceName4.app 包名appPa ...

  6. eas启动服务器时非法组件

    EAS实例启动报系统中存在非法组件,实例启动失败:   组件检查机制,要求除了 $EAS_HOME eas\server\lib: $EAS_HOME \eas\server\deploy\files ...

  7. C++ 类型转化(运算符重载函数)和基本运算符重载(自增自减)

    类型转化(运算符重载函数) 用转换构造函数可以将一个指定类型的数据转换为类的对象.但是不能反过来将一个类的对象转换为一个其他类型的数据(例如将一个Complex类对象转换成double类型数据).在C ...

  8. Codeforces 898D - Alarm Clock

    传送门:http://codeforces.com/contest/898/problem/D 有n个闹钟,第i(1≤i≤n)个闹钟将在第ai(1≤ai≤106)分钟鸣响,鸣响时间为一分钟.当在连续的 ...

  9. jQuery动态效果

    1.一号店首页 2.淘宝网购物车

  10. C#中三种弹出信息窗口的方式

    弹出信息框,是浏览器客户端的事件.服务器没有弹出信息框的功能. 方法一: asp.net页面如果需要弹出信息框,则需要在前台页面上注册一个javascript脚本,使用alert方法.使用Client ...