Codeforces Round #575 (Div. 3) 这个div3打的太差了,心态都崩了. B. Odd Sum Segments B 题我就想了很久,这个题目我是找的奇数的个数,因为奇数想分成x个奇数,那么这个x肯定是一个奇数, 偶数同理,如果一个偶数想分成y个奇数,那么这个y肯定是一个偶数. 所以数奇数的个数,如果奇数有x个,x是偶数,那么k一定是一个偶数,如果x是一个奇数,那么k肯定是一个奇数. 输出也比较简单,因为奇数要分成奇数个,所以可以前面每组都是含有一个奇数,最后肯定会有奇…
C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/D Description Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For ea…
B. Robin Hood 讲道理:这种题我是绝对不去(敢)碰的.比赛时被这个题坑了一把,对于我这种不A不罢休的人来说就算看题解也要得到一个Accepted. 这题网上有很多题解,我自己是很难做出来的,于是参考了一下思路,确实很niub的一个题.先记录下来将来回来也有个参考. 题意:有n个人,每个人有一定数量的硬币a[i],每天将最富有的一个人的一枚硬币给最穷的那个人.求k天后最富有的人与最穷的人的差为多少. 思路:两遍二分啊,前所未见.因为k是固定的,我们先将所有人所能达到的上下界求出来,比如…
B. Different is Good 题目连接: http://www.codeforces.com/contest/672/problem/B Description A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recently got a string s consisting of lowercase E…
A. Summer Camp 题目连接: http://www.codeforces.com/contest/672/problem/A Description Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solv…
->点击<- A. Summer Camp time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your f…
D. Searching Rectangles 题目连接: http://codeforces.com/contest/714/problem/D Description Filya just learned new geometry object - rectangle. He is given a field consisting of n × n unit cells. Rows are numbered from bottom to top with integer from 1 to…
题目链接: http://codeforces.com/contest/672/problem/C 题意: 公园里有两个人一个垃圾桶和n个瓶子,现在这两个人需要把所有的瓶子扔进垃圾桶,给出人,垃圾桶,瓶子的坐标,问两个人需要走的最短距离和. 题解: 首先必须要有一个人先去检一个瓶子,然后走到垃圾桶,这个可以枚举,接下来就是考虑另一个人是也捡一个瓶子然后走到垃圾桶(这个可以预处理出最优的,和次优的,因为如果最优的那个刚好被第一个人拿走了,那就拿次优的)还是在原地不动,接下去就是固定的了,求剩下的所…
A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/556/problem/A Description Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros an…
题目链接: http://codeforces.com/contest/672/problem/D 题意: 给你一个数组,每次操作,最大数减一,最小数加一,如果最大数减一之后比最小数加一之后要小,则取消操作,现在给你操作的次数,问操作之后最大数减最小数的最小值. 题解: 问题要求得是min(k次操作之后的最大数-k次操作之后的最小数),而这两个数可以独立求出来,我们先用二分求k次操作之后的最小数的最大取值,然后,再用二分求k次操作之后的最大数的最小可能取值. 代码: #include<algor…
题目链接:http://codeforces.com/contest/675/problem/C 给你n个bank,1~n形成一个环,每个bank有一个值,但是保证所有值的和为0.有一个操作是每个相邻的bank之间可以转钱,让你用最少的操作使每个bank的值为0. 一开始没什么思路,看了一下别人的题解,果然还是还是native... 要是让操作次数变少,首先划分和为0的区间个数要尽量多,比如一个区间的长度为k,那么他操作次数为k - 1,所以总的操作次数就是(n - 区间的个数). 那么要算出区…
题目链接:http://codeforces.com/contest/672/problem/D 有n个人,k个操作,每个人有a[i]个物品,每次操作把最富的人那里拿一个物品给最穷的人,问你最后贫富差距有多少. 先sort一下,最富的人很明显不会低于sum(a1 ~ an) / n , 所以二分一下最富人的最小值 看是否满足操作k. 最穷的人不会高于sum(a1 ~ an) / n + 1 ,所以二分一下最穷人的最大值 看是否满足操作k. (注意一点的是二分以后最穷的人的最大值和最富的人的最小值…
672A Summer Camp 题意: 1-n数字连成一个字符串, 给定n , 输出字符串的第n个字符.n 很小, 可以直接暴力. Code: #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int begin = 1; for(;;) { int dig = log10(begin) + 1; if(n <= dig) { char ss[10]; sprintf(ss…
B. Robin Hood 题目连接: http://www.codeforces.com/contest/671/problem/B Description We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citiz…
A. Recycling Bottles 题目连接: http://www.codeforces.com/contest/671/problem/A Description It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.…
B. Covered Path Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/B Description The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters per…
Problems     # Name     A Summer Camp standard input/output 1 s, 256 MB    x3197 B Different is Good standard input/output 2 s, 256 MB    x2870 C Recycling Bottles standard input/output 2 s, 256 MB    x664 D Robin Hood standard input/output 1 s, 256…
模拟 A - Summer Camp #include <bits/stdc++.h> int a[1100]; int b[100]; int len; void init() { int i = 1, tot = 1; while (tot <= 1010) { int t = i, c = 0; while (t) { b[c++] = t % 10; t /= 10; } for (int i=c-1; i>=0; --i) { a[tot++] = b[i]; } i++…
A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are different, he wants allsubstrings …
Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. Th…
D. Robin Hood   We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood…
C. Recycling Bottles   It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin. We can think Central Perk as coordinate plane. There are n bott…
C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A and B are preparing themselves for programming contests. An important part of preparing for a competition is s…
B. A and B and Compilation Errors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs t…
A. Stock Arbitraging 直接上代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> #include<stack> #include<set> #include<map> #include<vector> #include<cmath>…
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn't know…
题目大意 给出一棵树,边上有权值,要求给出一个1到n的排列p,使得sigma d(i, pi)最大,且p的字典序尽量小. d(u, v)为树上两点u和v的距离 题解:一开始没看出来p需要每个数都不同,直接敲了个轻重边剖分orz,交上去才发现不对 #include <iostream> #include <cstdio> #include <cstring> #include <vector> #define fi first #define se secon…
B. Robin Hood time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, a…
C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from t…
B. Different is Good time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recen…