思路:找规律?$or$贪心。

提交:1次

题解:

发现:若可以构成$X0000$,答案绝对不会再在数字最后把$0$改成其他数;

若可以构成$XX50...0$更优。

所以左端点增加的步长是增加的($inc=pow(10,x),x$递增)。

所以去掉了一些不必要的枚举。

#include<cstdio>
#include<iostream>
#include<cmath>
#define R register int
using namespace std;
#define ull unsigned long long
#define ll long long
#define pause (for(R i=1;i<=10000000000;++i))
#define In freopen("NOIPAK++.in","r",stdin)
#define Out freopen("out.out","w",stdout)
namespace Fread {
static char B[<<],*S=B,*D=B;
#ifndef JACK
#define getchar() (S==D&&(D=(S=B)+fread(B,1,1<<15,stdin),S==D)?EOF:*S++)
#endif
inline int g() {
R ret=,fix=; register char ch; while(!isdigit(ch=getchar())) fix=ch=='-'?-:fix;
if(ch==EOF) return EOF; do ret=ret*+(ch^); while(isdigit(ch=getchar())); return ret*fix;
} inline bool isempty(const char& ch) {return (ch<=||ch>=);}
inline void gs(char* s) {
register char ch; while(isempty(ch=getchar()));
do *s++=ch; while(!isempty(ch=getchar()));
}
} using Fread::g; using Fread::gs;
namespace Luitaryi {
int T,l,r; ll ans;
const ll Inf=1E+;
inline void main() {
T=g(); while(T--) { R mn=Inf;
l=g(),r=g();
while(l<=r) {
R x=l,cnt=;
while(x%==) x/=,++cnt;
R y=x,len=,lst=x%;
while(y) y/=,++len;
R tmp=*len-(lst==);
if(mn>tmp) mn=tmp,ans=l;
l+=pow(,cnt);
} printf("%lld\n",ans);
}
}
}
signed main() {
Luitaryi::main(); return ;
}

最新文章

  1. error-2015-9-9
  2. Android 5.x特性概览五
  3. Android中解析XML
  4. MySQL数据库学习笔记(六)----MySQL多表查询之外键、表连接、子查询、索引
  5. 个人介绍和GitHub
  6. Redis系列-存储篇string主要操作函数小结
  7. ado模版不会自动生成
  8. hdu 4752
  9. iOS 中 Touch ID得使用方法
  10. Ceph RBD CephFS 存储
  11. 安装好的虚拟机,外部通过ssh工具连接,报connection failed
  12. Call to undefined function mysql_connect()错误原因
  13. Mycat 分片规则详解--ASCII 取模范围分片
  14. LeetCode算法题-Relative Ranks(Java实现)
  15. scrapy爬虫之断点续爬和多个spider同时爬取
  16. python装饰器(备忘)
  17. docker应用-5(使用overlay 网络进行容器间跨物理主机通信)
  18. MUI学习01-顶部导航栏
  19. otter使用
  20. Jenkins自动化部署代码

热门文章

  1. LeetCode 第 164 场周赛
  2. tomcat单机多应用部署配合Nginx负载均衡
  3. (十六)JDBC 处理大数据
  4. ARM-常见考题和知识点
  5. # 双值Hash
  6. 关于Linux fontconfig 字体库的坑
  7. Redis 的订阅发布(PUB/SUB)示例
  8. javaScript节流与防抖
  9. flutter主题颜色
  10. Hadoop Shell 操作