13 November
[HEOI2015] 定价
BZOJ 4027: 在市场上有很多商品的定价类似于 999 元、4999 元、8999 元这样。它们和 1000 元、5000 元和 9000 元并没有什么本质区别,但是在心理学上会让人感觉便宜很多,因此也是商家常用的价格策略。不过在你看来,这种价格十分荒谬。于是你如此计算一个价格 p(p 为正整数)的荒谬程度:
1、首先将 p 看做一个由数字组成的字符串(不带前导 0);
2、然后,如果 p 的最后一个字符是 0,就去掉它。重复这一过程,直到 p 的最后一个字符不是 0;
3、记 p 的长度为 a,如果此时 p 的最后一位是 5,则荒谬程度为 2 * a - 1;否则为 2 * a。例如,850 的荒谬程度为 3,而 880 则为 4,9999 的荒谬程度为 8。
现在,你要出售一样闲置物品,你能接受的定价在 [L, R] 范围内,你想要给出一个荒谬度最低的价格。T ≤ 100,1 ≤ L ≤ R ≤ 10^9.
贪心。
#include <cstdio>
#include <cstring>
int T, L, R;
int ans;
inline int calc(int x) {
while (!(x%10)) x/=10;
register int k=x%10, a=0;
while (x) x/=10, ++a;
if (k==5) return (a<<1)-1; return a<<1;
}
inline int add(int x) {
register int k=1;
while (!(x%10)) x/=10, k*=10;
return k;
}
int main() {
for (scanf("%d", &T); T; --T) {
scanf("%d%d", &L, &R);
ans=L;
register int p=0x3f3f3f3f, q;
while (L<=R) {
q=calc(L);
if (p>q) p=q, ans=L;
L+=add(L);
}
printf("%d\n", ans);
}
return 0;
}
13 November的更多相关文章
- Alexander Grothendieck去世了
Alexander Grothendieck (German: [ˈɡroːtn̩diːk]; French: [ɡʁɔtɛndik]; 28 March 1928 – 13 November 201 ...
- doclint in jdk8
http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html Turning off doclint in JDK 8 ...
- Creating Custom UITableViewCells with NIB files
Maksim Pecherskiy 13 November 2012 Well this sucks. Apparently these days you can only use the Inter ...
- Intel processor brand names-Xeon,Core,Pentium,Celeron----Celeron
http://en.wikipedia.org/wiki/Celeron Celeron From Wikipedia, the free encyclopedia Celeron Produ ...
- GV900 Political Explanation
GV900 Political Explanation, 2017/201830 October, 2018Homework assignment 2Due Week 7 (13 November)W ...
- GIS和视频监控的集成
本文讨论了使用增强现实(AR)技术的三维(3D)地理信息系统(GIS)和视频监视系统的集成.进行这种集成的动机是要克服常规视频监视系统面临的问题.关于哪个摄像机当前监视此类系统中哪个区域的明确信息:因 ...
- Fix catalyst driver in Ubuntu 13.04 / 13.10
Fix catalyst driver in Ubuntu 13.04 / 13.10(墙外文章备份) 1. Introduction I found lots of people strugglin ...
- TIOBE Index for November 2015(转载)
原文地址:http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html November Headline: Java once a ...
- 日常英语---七、[Updated November 14 at 4:10 PM PST] Scheduled Game Update - November 14, 2018(n.标准)
日常英语---七.[Updated November 14 at 4:10 PM PST] Scheduled Game Update - November 14, 2018(n.标准) 一.总结 一 ...
随机推荐
- docker--docker 容器操作
6 docker 容器操作 容器是 docker 镜像的运行时实例. 6.1 创建容器 docker run [options] image command [ARG...]options选项: ‐i ...
- python 并发编程 多进程 模拟抢票
抢票是并发执行 多个进程可以访问同一个文件 多个进程共享同一文件,我们可以把文件当数据库,用多个进程模拟多个人执行抢票任务 db.txt {"count": 1} 并发运行,效率高 ...
- so easy(并查集+unordered_map)
There are nn points in an array with index from 11 to nn, and there are two operations to those poin ...
- Python基础编程闭包与装饰器
闭包的定义 闭包是嵌套在函数中的函数. 闭包必须是内层函数对外层函数的变量(非全局变量)的引用. 闭包格式: def func(): lst=[] def inner(a): lst.append(a ...
- Python yield用法浅析(stackoverflow)
这是stackoverflow上一个关于python中yield用法的帖子,这里翻译自投票最高的一个回答,原文链接 here 问题 Python中yield关键字的用途是什么?它有什么作用?例如,我试 ...
- C++编译器对属性的初始化检查远没有Java严格
C++编译器对属性的初始化检查远没有Java严格// Java编译通过:class yy { public static void main(String[] args) { int i; Syste ...
- PCIe事务层包TLP Header详解
1.事务层包的一般格式: 包的header为3DW(double word)或者4DW(一个DW代表4字节),数据负载为1~1024DW(即4~4096byte,最大4M),TLP Digest可选, ...
- vuex辅助函数和vuex5个属性
在上篇中,我们可以知道如果想要访问vuex.store中state中的数据,需要this.$store.state.属性名.显然这样访问数据写的代码很很不简洁的,辅助函数就是用来解决这个问题的. 1. ...
- 【学习总结】快速上手Linux玩转典型应用-目录
内容链接 慕课网:快速上手Linux玩转典型应用 目录 第1章-课程介绍 第2章-linux简介 第3章-CentOS的安装 第4章-准备工作 第5章-远程连接SSH专题 第6章-linux常用命令讲 ...
- JS 的 Browser对象
Window对象 closed innerHeight 窗口文档显示区的高度,包括滚动条 outerHeight 窗口总高度,包括工具条和滚动条 open() close() alert( ...