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…
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…
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++…
题目链接: http://codeforces.com/contest/672/problem/C 题意: 公园里有两个人一个垃圾桶和n个瓶子,现在这两个人需要把所有的瓶子扔进垃圾桶,给出人,垃圾桶,瓶子的坐标,问两个人需要走的最短距离和. 题解: 首先必须要有一个人先去检一个瓶子,然后走到垃圾桶,这个可以枚举,接下来就是考虑另一个人是也捡一个瓶子然后走到垃圾桶(这个可以预处理出最优的,和次优的,因为如果最优的那个刚好被第一个人拿走了,那就拿次优的)还是在原地不动,接下去就是固定的了,求剩下的所…
题目链接: http://codeforces.com/contest/672/problem/D 题意: 给你一个数组,每次操作,最大数减一,最小数加一,如果最大数减一之后比最小数加一之后要小,则取消操作,现在给你操作的次数,问操作之后最大数减最小数的最小值. 题解: 问题要求得是min(k次操作之后的最大数-k次操作之后的最小数),而这两个数可以独立求出来,我们先用二分求k次操作之后的最小数的最大取值,然后,再用二分求k次操作之后的最大数的最小可能取值. 代码: #include<algor…
题目链接: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…
题目链接:http://codeforces.com/contest/1138/problem/D 题目大意:给你两个字符串s1和s2(只包含0和1),对于s1中,你可以调换任意两个字符的位置.问你最多能在s1中构造出几个s2(可重叠). 具体思路:首先找到字符串s2的最小循环节,比如说1101,我们找到的最小循环节就是101,这样的话,我们每次在后面加上101就能构造出一个新的1101了,最小循环节是最小的代价. AC代码: #include<bits/stdc++.h> using nam…
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…