codefroces Round #201.a--Difference Row】的更多相关文章

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description You want to arrange n integers a1, a2, ..., an in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of a…
B. Fixed Points time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For ex…
A. Difference Row time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You want to arrange n integers a1, a2, ..., an in some order in a row. Let's define the value of an arrangement as the sum…
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); ; i < n; ++ i ) cin >>a[i]; sort(a.begin(),a.end()); swap(a[],a[n-]); ; i < n; ++i) co…
数论: C. Alice and Bob time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as fo…
C. Alice and Bob time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follow…
link:http://codeforces.com/contest/347/problem/A 开始看起来很复杂的样子,但是刚写下样例,就发现因为中间的都消去了,其实起作用的就是最大值和最小值=_= #include <cstdio> #include <algorithm> using namespace std; ]; int main(void) { #ifndef ONLINE_JUDGE freopen("in.txt", "r"…
题目链接:http://codeforces.com/problemset/problem/347/A 题目意思:给出一个序列 a1, a2, ..., an , 通过重排序列,假设变成 x1, x2, ..., xn ,使得 (x1 - x2) + (x2 - x3) + ... + (xn - 1 - xn)   的和最大.输出这个重排后的序列,不过这个序列在满足得到这个最大和的基础上字典序的排序是最小的.字典序排列即: Sequence x1, x2, ... , xp is lexico…
cf 上的一道好题:  首先发现能生成所有数字-N 判断奇偶 就行了,但想不出来,如何生成所有数字,解题报告 说是  所有数字的中最大的那个数/所有数字的最小公倍数,好像有道理:纪念纪念: #include<iostream> #include<stdio.h> #include<algorithm> #include<cstring> #include<algorithm> #include<cmath> using namespa…
题目链接:http://codeforces.com/contest/347/problem/C 题意是给你一个数n,然后n个数,这些数互不相同.每次可以取两个数x和y,然后可以得到|x - y|这个数,要求不在这个数组中,然后添加进去,直到不能取为止,不能取的人输了.Alice先取,求谁最后能赢. 可以先列举几种情况,可以发现,一般情况取到最后剩下1~max这些数了.但是要是比如原来的数有3 12这两个数,那最后就会剩下3 6 9 12这4个数,由此可以看出这种情况下剩下的一定是原来数的gcd…