Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For a positive integer n let's define a function f: f(n) =  - 1 + 2 - 3 + .. + ( - 1)n…
题目传送门 /* 贪心+构造:因为是对称的,可以全都左一半考虑,过程很简单,但是能想到就很难了 */ /************************************************ Author :Running_Time Created Time :2015-8-3 9:14:02 File Name :B.cpp *************************************************/ #include <cstdio> #include &…
门户:Codeforces Round #277 (Div. 2) 486A. Calculating Function 裸公式= = #include <cstdio> #include <cstring> #include <algorithm> using namespace std ; typedef long long LL ; LL n ; int main () { while ( ~scanf ( "%I64d" , &n )…
E. LIS of Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/problem/E Description The next "Data Structures and Algorithms" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence.…
D. Valid Sets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/problem/D Description As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consist…
B. OR in Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/problem/B Description Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if eith…
A. Calculating Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/problem/A 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…
题目地址:http://codeforces.com/contest/486 A题.Calculating Function 奇偶性判断,简单推导公式. #include<cstdio> #include<iostream> using namespace std; int main() { long long n; cin>>n; ==) { cout<<(-)*((n-)/+)+n<<endl; } else cout<<((n-…
题目链接:www.codeforces.com/problemset/problem/486/A题意:求表达式f(n)的值.(f(n)的表述见题目)C++代码: #include <iostream> using namespace std; long long f(long long n) { == ) ; else - n; } int main() { long long n; cin >> n; cout << f(n) << endl; ; } C…
A:SwapSort http://codeforces.com/problemset/problem/489/A 题目大意:将一个序列排序,可以交换任意两个数字,但要求交换的次数不超过n,输出任意一种方案即可 思路:真心想复杂了,排个序,然后按顺序把每个数交换到它应该在的地方即可 #include <stdio.h> #include <algorithm> #define maxn 40000 using namespace std; struct T{int x;int y;…