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. InnoDB undo log物理结构的初始化

    水平有限,如果有误请指出.一直以来未对Innodb 的undo进行好好的学习,最近刚好有点时间准备学习一下,通过阿里内核月报和自己看代码的综合总结一下.本文环境: 代码版本 percona 5.7.2 ...

  2. Uoj #218. 【UNR #1】火车管理 可持久化线段树+思维

    Code: #include<bits/stdc++.h> #define maxn 500005 using namespace std; int n,Q,ty,lastans=0; i ...

  3. 【第二课】kaggle案例分析二

    Evernote Export 推荐系统比赛(常见比赛) 推荐系统分类 最能变现的机器学习应用 基于应用领域分类:电子商务推荐,社交好友推荐,搜索引擎推荐,信息内容推荐等 **基于设计思想:**基于协 ...

  4. ArchLinux简单介绍

    一.Archlinux的由来 2002年由加拿大的Judd Vinet,Archlinux的创始人 怀着对Debian.Redhat的包管理器不满,于是创建了Archlinux!目前ArchLinux ...

  5. [BZOJ5072] 小A的树

    设计状态\(f[i][j]\)表示以i为根的子树,包含j个点的最小黑点数,\(g[i][j]\)表示以\(i\) 为子树,包含\(j\)个点的最大黑点数,然后树形背包转移即可. 每次询问的时候就看包含 ...

  6. ubuntu 配置lamp

    官方配置网站:http://wiki.ubuntu.org.cn/LAMP_%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%A ...

  7. 1.git的安装和配置

    从git官网下一个git安装包.   点击git.exe安装程序,点击[next]   点击[next]   根据自己的需要可以把需要安装软件全选上,点击[next]   由于这是个人使用所以选择第二 ...

  8. 使用requirejs模块化开发多页面一个入口js的使用方式

    描述 知道requirejs的都知道,每一个页面需要进行模块化开发都得有一个入口js文件进行模块配置.但是现在就有一个很尴尬的问题,如果页面很多的话,那么这个data-main对应的入口文件就会很多. ...

  9. 移位运算>>与>>>

    无符号右移运算符 (>>>)右移表达式的位,不保留符号.result = expression1 >>> expression2>>>运算符把 e ...

  10. 用DIME格式来组织自定义格式

    直接网际消息封装(Direct Internet Message Encapsulation,即DIME)格式提供了一种简单而又标准的机制,这个机制可以把多文本(multiple text)和二进制数 ...