Codeforces 352B - Jeff and Periods】的更多相关文章

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;…
题目链接:http://codeforces.com/problemset/problem/352/B 题目意思:给出一个长度为n的序列   a1, a2, ..., an(序号i,1 <= i <= n).需要从这个序列中,找出符合这两个条件的数:1.这个数在序列 a1, a2, ..., an 中: 2.该数的所有位置(也就是序号i)构成等差数列.一旦有一个位置不满足(此时和上一个位置所求出的公差就与之前的公差不相等),这个数就不符合条件,不应该输出.找完之后,输出所有满足这两个条件的数的…
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…
题目链接:http://codeforces.com/problemset/problem/351/D 题目大意:有n个数,每次可以删除掉数值相同并且所在位置成等差数列的数(只删2个数或者只删1个数应该也是可以的),删掉这些数以后可以将剩下的数重新以任意顺序排列,称为一次操作.现在给出m个询问,每个询问一个区间[l,r],问删光区间[l,r]中的数最少需要的操作次数. 解题思路: 由于一次操作之后可以以任意顺序排序,所以可以把相同数字排成等差的以便删除,那接下来就只要判断这个区间还有几种数字,一…
题目链接:http://codeforces.com/problemset/problem/351/B 题意: 给你一个1到n的排列a[i]. Jeff和Furik轮流操作,Jeff先手. Jeff每次会交换a[i]>a[i+1]的两个数. Furik每次有1/2的概率交换a[i]<a[i+1]的两个数,有1/2的概率交换a[i]>a[i+1]的两个数. 当这个排列变成升序时,游戏停止. 问你操作数的期望. 题解: 假设原序列中有t个逆序对. 那么将这个序列变成升序,就是将这t个逆序对一…
题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这个序列尽可能地大,并且能被90除尽. 做这道题目,是多次调试本场比赛的B,完全不成功后回头再做的,一开始什么思路都没有,因为觉得是考纯数学,直接看B......怎么说,很大程度是靠直觉的.只知道,这个序列肯定是这种形式:5xx...0 或者像题目所说的特殊情况:0(不过前提是0的个数不为0).其他就…
C. Jeff and Rounding time limit per test:  1 second memory limit per test: 256 megabytes input: standard input output: standard output Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided t…
题目链接:http://codeforces.com/contest/351/problem/A 算法思路:2n个整数,一半向上取整,一半向下.我们设2n个整数的小数部分和为sum. ans = |A - B|; sum = A +(n-b)-B; 所以ans = |sum - (n-b) |; 只有b未知,只需要枚举一下b就得到答案. #include<cstdio> #include<iostream> #include<algorithm> #include<…
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==…