Codeforces Round #299 Div2 解题报告
这场比赛并没有打现场,昨天晚上做了ABCD四道题,今天做掉了E题
以前还没有过切完一场比赛的所有题呢~爽~
A. Tavas and Nafas
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.
His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words.
He ate coffee mix without water again, so right now he's really messed up and can't think.
Your task is to help him by telling him what to type.
最简单的模拟题..我还是喜欢定义三个常量来解决~跪跪手速帝(由于不是现场打所以慢悠悠地写
心想如果是现场应该会紧张拼错好多个单词WA掉吧..QAQ
B. Tavas and SaDDas
Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."
The problem is:
You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
If we sort all lucky numbers in increasing order, what's the 1-based index of n?
Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.
首先我们需要统计所有位数小于这个数的数字
显然n为位lucky number有2^n个
然后接下来对于每一位,我们统计:
所有在这一位前的都等于原数,这一位小于原数的数
所以只有当某位为7的时候我们才累加答案
也就是这一位后面可以随意取
最后答案+1输出即可
C. Tavas and Karafs
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.
Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + (i - 1) × B.
For a given m, let's define an m-bite operation as decreasing the height of at most m distinct not eaten Karafses by 1. Karafs is considered as eaten when its height becomes zero.
Now SaDDas asks you n queries. In each query he gives you numbers l, t and m and you should find the largest number r such that l ≤ r and sequence sl, sl + 1, ..., sr can be eaten by performing m-bite no more than t times or print -1 if there is no such number r.
C题首先我们需要证明一个东西:
对于一个区间[l,r]若(m*t>=sigma(s[i])(l<=i<=r))&(t>=max(s[i])(l<=i<=r))那么这个区间满足要求
刚开始觉得这个结论并不正确...
后来思考了一下,首先很显然,任意一个条件不满足肯定不可行,必要性得证
接着,我们思考m<=(r-l+1)的时候,我们每次都可以在剩下的地方取m个
由于m*t>=sigma(s[i]),所以显然是取得完的
m>(r-l+1)的时候,我们每次都把所有l~r的数取一遍,由于t>=max(s[i]),所以显然也是取得完的
充分性得证
接下来简单的二分的就可以了
D. Tavas and Malekas
Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead.
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < x2 < ... < xk where p matches s. More formally, for each xi (1 ≤ i ≤ k) he condition sxisxi + 1... sxi + |p| - 1 = pis fullfilled.
Then Malekas wrote down one of subsequences of x1, x2, ... xk (possibly, he didn't write anything) on a piece of paper. Here a sequence b is a subsequence of sequence a if and only if we can turn a into b by removing some of its elements (maybe no one of them or all).
After Tavas woke up, Malekas told him everything. He couldn't remember string s, but he knew that both p and s only contains lowercase English letters and also he had the subsequence he had written on that piece of paper.
Tavas wonders, what is the number of possible values of s? He asked SaDDas, but he wasn't smart enough to solve this. So, Tavas asked you to calculate this number for him.
Answer can be very large, so Tavas wants you to print the answer modulo 109 + 7.
D题意很简单,就是给出给出一个字符串p,和它在字符串s中的一些匹配位置,以及s的位数
判断是否存在这样的字符串,以及存在的话这样的字符串的个数
首先,匹配位置是所有匹配位置的subsequence实际上是对问题的简化,我们考虑其他位置的时候
就不需要再考虑是否又构成了一次匹配
然后对于s的个数其实很简单...我们考虑匹配完全不重叠的情况,那些没有p覆盖的位置位数设为x
则26^x就是答案
然而实际上这道题的主要问题都在判断是否存在,简单的扩展KMP的应用
//再去巩固一下KMP 扩展KMP 后缀数组这些东西各个数组的含义 以免下次套用错算法
E. Tavas and Pashmaks
Tavas is a cheerleader in the new sports competition named "Pashmaks".
This competition consists of two part: swimming and then running. People will immediately start running R meters after they finished swimming exactly S meters. A winner is a such person that nobody else finishes running before him/her (there may be more than one winner).
Before the match starts, Tavas knows that there are n competitors registered for the match. Also, he knows that i-th person's swimming speed is si meters per second and his/her running speed is ri meters per second. Unfortunately, he doesn't know the values of R and S, but he knows that they are real numbers greater than 0.
As a cheerleader, Tavas wants to know who to cheer up. So, he wants to know all people that might win. We consider a competitor might win if and only if there are some values of R and S such that with these values, (s)he will be a winner.
Tavas isn't really familiar with programming, so he asked you to help him.
E题首先我们可以把每个人的两个数据(x,y)转化成(1/x,1/y)将新数设为(a,b)
最后的答案s/x+r/y=sx+ry
我们考虑1,3,2三个点,4是3号点作与x轴的平行线与线段12的交点
首先,与合金问题相似,我们设1(x1,y1),2(x2,y2)
4(ax1+bx2,ay1+by2),ans = s(ax1+bx2) + r(ay1+by2)
= a(sx1+ry1)+b(sx2+ry2) (0<a,b<1)
不仅4号点的x,y坐标是1,2两点的混合,最后的ans也是x,y答案的混合
那么也就是min(ans1,ans2)<=ans4<=max(ans1,ans2)
然而3号点显然答案<4号点,所以3号点不可能成为winner
于是转化成了凸包的问题
然而需要注意几个问题
1)加的点:我们需要加右上角左上角右下角各一点来维护凸包
然而左上与右下不能直接等于边界的值,因为这样就不能去除掉边上的点
然而也不能大于边界的值太多..因为可能会排除掉很多不应该排除的点
所以最后赋一个边界的值-eps 卡卡精度应该就可以了(可是考试的时候怎么办啊TAT
2)精度问题:判一判eps
3)重点问题:显然做Graham算法是不能存在重点的
于是我们添加的时候加一条if语句重点不再进
最后累积答案的时候再处理一下即可
还是非常喜欢CF的题,由于时间限制的关系不会出一些数据结构题
平时多做做这样的题练练思维和手速真的很棒
还有以后还是尽量打现场,会有不一样的感受
20/.Apr.
Codeforces Round #299 Div2 解题报告的更多相关文章
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round 665 赛后解题报告(暂A-D)
Codeforces Round 665 赛后解题报告 A. Distance and Axis 我们设 \(B\) 点 坐标为 \(x(x\leq n)\).由题意我们知道 \[\mid(n-x)- ...
- Codeforces Round 662 赛后解题报告(A-E2)
Codeforces Round 662 赛后解题报告 梦幻开局到1400+的悲惨故事 A. Rainbow Dash, Fluttershy and Chess Coloring 这个题很简单,我们 ...
- Codeforces Round #277.5 解题报告
又熬夜刷了cf,今天比正常多一题.比赛还没完但我知道F过不了了,一个半小时贡献给F还是没过--应该也没人Hack.写写解题报告吧= =. 解题报告例如以下: A题:选择排序直接搞,由于不要求最优交换次 ...
- Codeforces Educational Round 92 赛后解题报告(A-G)
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
随机推荐
- django 解决cors问题
首页 博客 学院 下载 GitChat TinyMind 论坛 问答 商城 VIP 活动 招聘 ITeye CSTO 写博客 发Chat 登录注册 AFei0018-博客 穷则思变,差则思勤.Pyth ...
- android开源项目之OTTO事件总线(二)官方demo解说
官方demo见 https://github.com/square/otto 注意自己该编译版本为2.3以上,默认的1.6不支持match_parent属性,导致布局文件出错. 另外需要手动添加an ...
- 数据结构7——BFS
一.重拾关键 宽度优先搜索,也有称为广度优先搜索,简称BFS.类似于树的按层次遍历的过程. 初始状态:图G所有顶点均未被访问过,任选一点v. 遍历过程:假设从图中某顶点v出发,在访问了v之后依次访问v ...
- 第四次JAVA作业
public class TvbDog { public static void main(String[] args) { Dog per=new Dog("陈狗"," ...
- SQL Server Profiler的简单使用,方便查找和发现SQL执行的效率和语句问题
1 打开Server Profiler 2 去掉不必要的干扰,数据库的连接和断开之类的 3. 选择“显示所有列”,之后在列表中,勾选“DatabaseName”项. 4设置筛选器,这里设置只是过滤数据 ...
- delphi数据库进行增加操作时,怎么判断插入的这个值是否已经存在?
//增 procedure TForm1.btnAddClick(Sender: TObject); begin ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQu ...
- Spring 集成Quartz
在使用jdk的timer时发现无法在指定的日期进行执行任务.这便引入一个优秀的开源任务调度框架“quartz”.这里使用的是quartz-1.8.6版本.Quart的官网:http://www.qua ...
- BZOJ 3876:支线剧情(有下界最小费用最大流)
3876: [Ahoi2014]支线剧情 Description [故事背景]宅男JYY非常喜欢玩RPG游戏,比如仙剑,轩辕剑等等.不过JYY喜欢的并不是战斗场景,而是类似电视剧一般的充满恩怨情仇的剧 ...
- 习题:就是干(DP)
洛谷2301 题目描述 眼看着老师大军浩浩荡荡的向机房前进.LOI 的同学们决定动用自己的力量来保卫他们的好朋友loidc.现在每个人都要挑选自己的武器——两根木棍.一根用做远距离投掷,另一根用做近距 ...
- 【bzoj3940】[Usaco2015 Feb]Censoring AC自动机
题目描述 Farmer John has purchased a subscription to Good Hooveskeeping magazine for his cows, so they h ...