B. Beautiful Paintings 题目连接: http://www.codeforces.com/contest/651/problem/B Description There are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting…
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes…
D. Image Preview 题目连接: http://www.codeforces.com/contest/651/problem/D Description Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
A. Joysticks time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at…
DFS A - Joysticks 嫌麻烦直接DFS暴搜吧,有坑点是当前电量<=1就不能再掉电,直接结束. #include <bits/stdc++.h> typedef long long ll; const int N = 1e5 + 5; int ans = 0; void DFS(int a, int b, int step) { if (a <= 0 || b <= 0) { ans = std::max (ans, step); return ; } if (a…
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes…
C. Beautiful Numbers 题目连接: http://www.codeforces.com/contest/300/problem/C Description Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains…
链接: https://codeforces.com/contest/1182/problem/C 题意: You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyric…
链接: https://codeforces.com/contest/1265/problem/E 题意: Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability pi100 for al…
链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to 1. More formally, a sequence s1,s2,-,sn is beautiful if |si−si+1|=1 for all 1≤i≤n−1. Trans…
链接: https://codeforces.com/contest/1265/problem/C 题意: So the Beautiful Regional Contest (BeRC) has come to an end! n students took part in the contest. The final standings are already known: the participant in the i-th place solved pi problems. Since…
链接: https://codeforces.com/contest/1265/problem/B 题意: You are given a permutation p=[p1,p2,-,pn] of integers from 1 to n. Let's call the number m (1≤m≤n) beautiful, if there exists two indices l,r (1≤l≤r≤n), such that the numbers [pl,pl+1,-,pr] is a…
链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa&…
题目链接:http://www.codeforces.com/problemset/problem/271/A题意:给你一个四位数,求比这个数大的最小的满足四个位的数字不同的四位数.C++代码: #include <iostream> #include <algorithm> using namespace std; bool chk(int x) { ]; ; i < ; i ++) { a[i] = x % ; x /= ; } sort(a, a + ); ; i &l…
题目链接: http://codeforces.com/problemset/problem/650/C C. Table Compression time limit per test4 secondsmemory limit per test256 megabytes 问题描述 Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and m…
E. Clockwork Bomb 题目连接: http://www.codeforces.com/contest/650/problem/E Description My name is James diGriz, I'm the most clever robber and treasure hunter in the whole galaxy. There are books written about my adventures and songs about my operations…
D. Zip-line 题目连接: http://www.codeforces.com/contest/650/problem/D Description Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in t…
E. Table Compression 题目连接: http://www.codeforces.com/contest/651/problem/E Description Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many others. Inspired by the new knowledge, Petya is now…
C. Watchmen 题目连接: http://www.codeforces.com/contest/651/problem/C Description Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watch…
A. Joysticks 题目连接: http://www.codeforces.com/contest/651/problem/A Description Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2…
A. Beautiful Year time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after t…
题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只有成功了才会进入下一步,失败了会从第 \(1\) 步重新开始测.请问成功的期望步数是多少? 解题思路: 设期望步数是 \(S\) ,则有公式如下: 实现代码如下: #include <bits/stdc++.h> using namespace std; typedef long long ll;…
题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母,问能否字符串中所有相邻字母都不同. 题解 除非一开始字符串就不合法,否则一定可以构造出合法的字符串,因为共有三个字母可选,而替换时最多需要判断前后两个位置. 代码 #include <bits/stdc++.h> using namespace std; void solve() { strin…
题目链接:https://codeforces.com/contest/1265/problem/B 题意 给出大小为 $n$ 的一个排列,问对于每个 $i(1 \le i \le n)$,原排列中是否有一个大小为 $i$ 的连续子排列. 题解 从小到大构造排列,记录当前排列中数的最小下标和最大下标,若最小下标和最大下标的间距刚好为排列的长度,则说明大小为 $i$ 的排列是连续的. 代码一 #include <bits/stdc++.h> using namespace std; void s…
题目链接:https://codeforces.com/contest/1265/problem/C 题意 从大到小给出 $n$ 只队伍的过题数,要颁发 $g$ 枚金牌,$s$ 枚银牌,$b$ 枚铜牌,要求: $g < s, g < b$ $g + s + d \le \lfloor \frac{n}{2} \rfloor$ 金牌队伍的过题数大于银牌,银牌队伍的过题数大于铜牌 输出颁发奖牌数最多的一种方案. 题解 根据第三个要求,奖牌一定是按过题数的大小颁发的. 金牌只颁发给过题最多数的队伍,…
A. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. The…
C. Table Compression Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many others. Inspired by the new knowledge, Petya is now developing the new compression algorithm which he wants to name d…
Watchmen 题意:有n (1 ≤ n ≤ 200 000) 个点,问有多少个点的开平方距离与横纵坐标的绝对值之差的和相等: 即 = |xi - xj| + |yi - yj|.(|xi|, |yi| ≤ 109) 思路:开始想的是容斥原理,即按x,y分别排序,先计算同x的点,然后在计算同y的点,这时由于相同的点之间的连边已经算过了,这样就不能再算.并且同一个y的点中可以每个点有多个点,算是不好编码的(反正我敲了很久..WA了) 反思:上面的容斥原理是从总体的思路来考虑的,这道题的难点也就是…
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly,…