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; ][] = {" ...
随机推荐
- 『Golang』MongoDB在Golang中的使用(mgo包)
有关在Golang中使用mho进行MongoDB操作的最简单的例子.
- python接口自动化: CAS系统验证,自动完成登录并获取token,遇到302请求重定向设置(requests模块 allow_redirects=False)即可
import requestsimport re import requests import re class Crm_token(object): try: username=int(input( ...
- python学习总结----内置函数及数据持久化
抽象基类(了解) - 说明: - 抽象基类就是为了统一接口而存在的 - 它不能进行实例化 - 继承自抽象类的子类必须实现抽象基类的抽象方法 - 示例: from abc import ABC, abs ...
- lintcode-135-数字组合
135-数字组合 给出一组候选数字(C)和目标数字(T),找到C中所有的组合,使找出的数字和为T.C中的数字可以无限制重复被选取. 例如,给出候选数组[2,3,6,7]和目标数字7,所求的解为: [7 ...
- lintcode-52-下一个排列
52-下一个排列 给定一个整数数组来表示排列,找出其之后的一个排列. 注意事项 排列中可能包含重复的整数 样例 给出排列[1,3,2,3],其下一个排列是[1,3,3,2] 给出排列[4,3,2,1] ...
- Tomcat 中如何给 web 项目配置虚拟目录的方法
为什么要给 web 项目配置虚拟目录? 初学 JavaWeb 时,会发现只要我们把 web 项目放到 Tomcat 的 webapps 目录下,再通过 http://localhost:8080/项目 ...
- 【EasyNetQ】- 简介
EasyNetQ是一个简单易用的,稳定的的RabbitMQ .NET API . 如果您只想尽快启动并运行,请转到“ 快速开始”指南. EasyNetQ的目标是提供一个库,使得在.NET中使用Rabb ...
- JSP表单提交出现中文乱码的解决方法
1)post方式 在servlet的doGet( ) doPost( ) 中增加以下代码: response.setContentType("text/html;charset=utf- ...
- Hibernate domain对象说明
一个domain对象对应于数据库的一张表(也可以表示出表关系) domain对象必须带一个无参构造函数 建议有一个无意义id,作为主键 建议非final,否则无法使用Hibernate的高级特性(懒加 ...
- ES 1.7安装ik分词elasticsearch-analysis-ik-1.2.5
IK简介 https://www.cnblogs.com/yjf512/p/4789239.html https://www.cnblogs.com/xing901022/p/5910139.html ...