Codeforces Round #300

A. Cutting Banner

关键字:[读题][字符串][枚举]

坑点:能不能只减去某一段字符串把剩下的按原来的顺序连起来组成"CODEFORCES",而减下一段"CODEFORCES"是不行的

e.g. "CODEFAAAAORCES"是可行的         而 "AACODEFORCESAA"是不可行的

B. Quasi Binary

题意:给出一个数n,求最少用几个形如"1010"这样只包含‘0‘和‘1’的数相加得到

关键字:[贪心]

解法:因为每次最多使n的每位减少1,总次数就是n的所有位中最大的数。如果n的某位不为0就减少1,为0不变,去除前导0,就是每次需要的数

C. Tourist‘s Notes

题意:一个人去爬山,已知n天中某m天的爬山高度,且相邻两天的高度差$\leq 1$,求这个人在这n天中爬的最高高度是多少,如果矛盾输出-1

关键字:[数学公式]

解法:显然如果相邻的两天的高度差大于时间差一定是"IMPOSSIBLE"。最高的高度一定在某相邻的两个时间点之间出现。设相邻的两个时间点为$dx,dy(dx < dy)$,高度分别为$hx$,$hy$,取得最高点时一定是从$dx$向右增加,$dy$向左增加时相差最小的点,设为$p (dx \leq p \leq dy)$。从$dx$经过$p$天,$dx$的高度$dpx = hx + p$ ,$dy$的高度$dpy = hy + ((dy-dx)-p)$, 令$dpx = dpy$ ,解得 $p = (hy-hx+dy-dx)/2$,则此段的最高高度为$hx + p = (hy+hx-dy-dx)/2$,维护m+1段就行了(包括头尾)

D. Weird Chess

题意:

时间: 2024-08-28 14:26:11

Codeforces Round #300的相关文章

Codeforces Round #300 (A,B,C,D)

题目传送:Codeforces Round #300 A. Cutting Banner 思路:一看题就会错意了,然后一顿猛敲,果不其然的被hack了,然后才发现只需要剪中间那一段就可以了,然后又傻逼得少写一个等号,还是被hack了,心累啊 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> #in

Codeforces Round #300——C贪心——Tourist&#39;s Notes

Description A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, me

贪心 Codeforces Round #300 A Cutting Banner

题目传送门 1 /* 2 贪心水题:首先,最少的个数为n最大的一位数字mx,因为需要用1累加得到mx, 3 接下来mx次循环,若是0,输出0:若是1,输出1,s[j]--: 4 注意:之前的0的要忽略 5 */ 6 #include <cstdio> 7 #include <iostream> 8 #include <cstring> 9 #include <string> 10 #include <algorithm> 11 #include

水题 Codeforces Round #300 A Cutting Banner

题目传送门 1 /* 2 水题:一开始看错题意,以为是任意切割,DFS来做:结果只是在中间切出一段来 3 判断是否余下的是 "CODEFORCES" :) 4 */ 5 #include <cstdio> 6 #include <iostream> 7 #include <cstring> 8 #include <string> 9 #include <algorithm> 10 #include <cmath>

Codeforces Round #300 B

B. Quasi Binary A number is called quasibinary if its decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011 - are quasibinary and numbers 2, 12, 900 are not. You are given a positive integer n. Represent it as a s

Codeforces Round #300 - Quasi Binary(贪心)

Quasi Binary Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description A number is called quasibinary if its decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011 - ar

Codeforces Round #300 E - Demiurges Play Again

E - Demiurges Play Again 感觉这种类型的dp以前没遇到过... 不是很好想.. dp[u] 表示的是以u为子树进行游戏得到的值是第几大的. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define y1 skldjfskldjg #define y

Codeforces Round #257 (Div. 2)

A.Jzzhu and Children 计算每个人会出现的轮次数,取最后一个且轮次数最大的,注意是用a[i]-1 % m,倒着扫一遍就行了 #include <iostream> #include <cstdio> #include <cstdlib> using namespace std; const int maxn = 100+10; int n, m; int a[maxn]; int main() { #ifdef LOCAL freopen("

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/