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; ][] = {" ...
随机推荐
- 创龙TMS320C6748开发板串口和中断学习笔记
1. 硬件上,底板有2个串口,UART1和UART2(使用了MAX3232电平转换芯片),其中UART2也可以转RS485的. 2. 看下数据手册部分,不过一直不理解过采样的意思,16字节的FIFO ...
- kettle 遇到 解决Incorrect integer value: '' for column 'id' at row 1 完美解决-费元星
最近自己在测试一个开源的程序,测试中发现.该程序都添加和更新的时候回出现 Incorrect integer value: '' for column 'id' at row 1类是的错误! 后来我自 ...
- 安装mathtype出问题卸载后 office2016打开mathtype弹错误窗口
解决方法:找到 C:\Program Files (x86)\Microsoft Office\root\Office16\STARTUP目录下的MathType Commands 6 For Wor ...
- Ubuntu 添加中文字体
查看系统类型 cat /proc/version 查看中文字体 fc-list :lang=zh-cn 安装字体 sudo apt install -y --force-yes --no-instal ...
- npm命令 VS yarn命令
npm yarn 说明 npm init yarn init 在项目中引导创建一个package.json文件 npm install yarn install/yarn 安装所有依赖包(依据pa ...
- 【java并发编程实战】第七章:取消与关闭
停止线程的几种方式 一般的逻辑停止 public class ThreadInterruptTest { public static volatile boolean cancel = true; p ...
- get? post? put? delete? head? trace? options? http请求方法
http1.1协议里面定义了八种请求方法: get:用作获取,读取数据 post:向指定的资源提交数据 put:更新,向指定的资源上传一个内容,比如说:更新一个用户的头像或者替换掉已有的一个视频 de ...
- flex builder 4
下载地址(需要登录):http://trials.adobe.com/AdobeProducts/FLBR/4/win32/FlashBuilder_4_LS10.exe 很全的在线帮助文档:http ...
- C++关于堆的函数
建立堆 make_heap(_First, _Last, _Comp) 默认是建立最大堆的.对int类型,可以在第三个参数传入greater<int>()得到最小堆. 在堆中添加数据 ...
- Java 对象及其内存控制
作者:禅楼望月(http://www.cnblogs.com/yaoyinglong) 更新:其实这里有好多的变戏法,只要你理解了他们在JVM的中的实现机制,就豁然开朗了.有时间我会把这些变戏法的东西 ...




