cf B. Jeff and Periods】的更多相关文章

http://codeforces.com/contest/352/problem/B #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ]; int n; ]; int len; struct node { int x,id; bool operator <(const node &a)const { return (x<a.x)||(x==…
B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequ…
B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequ…
352B - Jeff and Periods 思路:水题,考验实现(implementation)能力,来一波vector[允悲]. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset((a),(b),sizeof(a)) ; vector<int>g[N]; vector<int>ans;…
One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which these conditions hold: x occurs in sequence a. Consider all positions…
题目链接:http://codeforces.com/problemset/problem/352/B 题目意思:给出一个长度为n的序列   a1, a2, ..., an(序号i,1 <= i <= n).需要从这个序列中,找出符合这两个条件的数:1.这个数在序列 a1, a2, ..., an 中: 2.该数的所有位置(也就是序号i)构成等差数列.一旦有一个位置不满足(此时和上一个位置所求出的公差就与之前的公差不相等),这个数就不符合条件,不应该输出.找完之后,输出所有满足这两个条件的数的…
/* * c.cpp * * Created on: 2013-10-7 * Author: wangzhu */ #include<cstdio> #include<iostream> using namespace std; #define NMAX 100010 struct Node { //index:表示两个数直接的距离(-1:表示未开始,0:表示开始:> 0:表示有了距离 //val:记录最后一次的位置 //flag:不符合条件 (0:表示符合条件,1:表示不符…
题意: 两人游戏, J先走. 给出一个1~n的排列, J选择一对相邻数[题意!!~囧], 交换. F接着走, 扔一硬币, 若正面朝上, 随机选择一对降序排列的相邻数, 交换. 若反面朝上, 随机选择一对升序排列的相邻数, 交换. 当数列成为严格升序的时候游戏结束. 求让游戏尽早结束的情况下, 移动次数的期望. 思路: 首先分析游戏结束的方法: 由于是排列, 严格升序就是1~n. J的话..直接按顺序将较小的数交换到目标位置即可. F的话...比较麻烦, 有两种可能, 每种可能都是随机的.....…
http://codeforces.com/contest/352/problem/C 题意:给予N*2个数字,改变其中的N个向上进位,N个向下进位,使最后得到得数与原来数的差的绝对值最小 对每一个浮点数都取其下限,得到的差值就是所有浮点数小数部分的和:然后则需要从2*n个数里面选出n个数取其上限,即下限加1,而如果这个数是个整数,那么不需要加1:因此统计加1个数的上限和下限即可:然后选择min abs(小数部分的和-加1的个数): #include <cstdio> #include <…
http://codeforces.com/contest/352/problem/A #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n; ]; int main() { ,t2=; scanf("%d",&n); ; i<=n; i++) { scanf("%d",&a[i]); ) t1…