Codeforces Round #277 (Div. 2) A. Calculating Function 水题
A. Calculating Function
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/486/problem/A
Description
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.
Sample Input
4
Sample Output
2
HINT
题意
f(n) =  - 1 + 2 - 3 + .. + ( - 1)^n
给你n,然后让你求f(n)
题解:
分奇偶啦,奇数就是(n-1)/2-n,偶数就是n/2
代码
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
long long n;scanf("%lld",&n);
if(n%==) printf("%lld\n",(n-1LL)/2LL - n);
else printf("%lld\n",n/2LL);
}
Codeforces Round #277 (Div. 2) A. Calculating Function 水题的更多相关文章
- 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 + ...
 - Codeforces Round #277 (Div. 2)---A. Calculating Function   (规律)
		
Calculating Function time limit per test 1 second memory limit per test 256 megabytes input standard ...
 - 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 ...
 - Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
		
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
 - 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 ...
 - Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题
		
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...
 - Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题
		
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...
 - Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
		
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
 - Codeforces Round #146 (Div. 1) A. LCM Challenge 水题
		
A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...
 
随机推荐
- Jquery获取第一个子元素
			
如获取id为divId的div下的第一个子div $("#divId").children("div").get(0) 但得到的是一个dom对象,如果要得到Jq ...
 - CodeForces 54C-First Digit Law(数位,概率dp)
			
题意: 给你n个区间,在每个区间里各取一个数(随机取),求这n个数中超过K%的数是首位为1数的概率 分析: dp[i][j]取前i个数,有j个是首位为1的数的概率 易知,dp[i][j]=dp[i-1 ...
 - ubuntu开发软件的安装
			
今天下午发现ubuntu12.04坏了,无奈只能重新安装,建议读者配置自己的ubuntu后备份一个,免得坏了重新安装,花了两个小时才把ubuntu的交叉环境弄好,其中搭建了tptp通信协议,还有arm ...
 - 关于CCSprite改变box2d刚体位置以及角度。
			
同事今天在讨论一个事情,box2d中,body不可以直接设置位置,这样是不合理的,因为在物理的世界,你去左右它的物理检测.它就没有存在的必要了.但是,有人就想直接用box2d的碰撞.不用物理模拟.怎么 ...
 - 【跟我一起学python吧】python chr()、unichr()和ord()
			
chr().unichr()和ord() chr()函数用一个范围在range(256)内的(就是0-255)整数作参数,返回一个对应的字符.unichr()跟它一样,只不过返回的是Unicode字符 ...
 - Canvas入门(2):图形渐变和图像形变换
			
来源:http://www.ido321.com/986.html 一.图形渐变(均在最新版Google中测试) 1.绘制线性渐变 1: // 获取canvas 的ID 2: var canvas = ...
 - 一个鼠标键盘控制两台甚至多台主机的方法--Synergy
			
在多台主机,不同系统中操作.避免了更换键鼠的麻烦.即使下面图中的功能. 鼠标同时在三台或者多台主机之间进行移动,而且是无缝滑动,鼠标直接从左滑倒右,而且支持,这台电脑复制,另一台黏贴.非常的方便实用. ...
 - How do I use SOCKS proxy in delphi?
			
TCP====== For Indy 8.0 In Delphi, do the following: IdTCPClient1.SocksInfo.Host := [the DNS name of ...
 - 搭建Titanium开发环境
			
轻松制作 App 再也不是梦! Titanium Mobile 让你能够使用你所熟悉的 web 技术,制作出如同使用Objective-C 或 Java 写出的 Native App. 除了有多达三百 ...
 - Android强大的开源库与系统架构工具
			
后来加上的,因为太强大了,android上百个可立即使用的开源库介绍:https://github.com/Trinea/android-open-project 一款功能强大且实用的开发工具可以为开 ...