BZOJ4612——[Wf2016]Forever Young
1、题意:将一个数y转化成b进制数,使得他>=l,且<y,且转化后均为0~9,使b最大。
2、分析:我们发现要么答案的b很小,要么y很小。。那我们直接暴力枚举就好了啊
然后判断一下。。。另外给一个数,判断进制的时候需要二分。。。这个二分就是一个方程= =
解一解就好了= =
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; #define LL long long inline LL read(){ char ch = getchar(); LL x = 0, f = 1; while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while('0' <= ch && ch <= '9'){ x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } LL y, lo; inline LL check(LL x, LL o){ LL ret = 0; ret += o % 10; ret += o % 100 / 10 * x; ret += o / 100 * x * x; return ret; } inline bool checker(LL u, LL t){ LL x = t, tot = 0, ot = 0; t = 1; while(x){ if(x % u >= 10) return true; ot = ot + x % u * t; t = t * 10; x /= u; } if(ot < lo) return true; return false; } int main(){ //freopen("for.in", "r", stdin); //freopen("for.out", "w", stdout); LL ans = 0; y = read(), lo = read(); for(LL i = lo; i <= 999; i ++){//sou number LL l = 1, r = 1e9, t = 1; if(i < 100) r = 1e18; while(l <= r){ LL mid = (l + r) / 2; if(check(mid, i) <= y) l = (t = mid) + 1; else r = mid - 1; } if(check(t, i) == y){ ans = max(ans, t); } // if(i == 10) printf("%lld %lld\n", t, ans); } for(LL i = 1000000; i >= ans; i --){ // printf("%d\n", i); if(i < 2) continue; if(checker(i, y)) continue; printf("%d\n", i); return 0; } printf("%lld\n", ans); return 0; }
BZOJ4612——[Wf2016]Forever Young的更多相关文章
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- Java:网络编程
一.因特网地址 InetAddress类:实现主机名和因特网地址之间的转换. InetAddress address=InetAddress.getByName(String);返回一个InetAdd ...
- 2017人生总结(MECE分析法)
试着用MECE分析法对人生的整个规划做一下总结.作为技术人员,其实除了编码架构能力之外,分析问题的能力的重要程度也会随着职业发展越来越重要.<美团点评技术博客>说这几天要在黄金时段头版头条 ...
- November 08th, 2017 Week 45th Wednesday
Keep your face to the sunshine and you cannot see the shadow. 始终面朝阳光,我们就不会看到黑暗. I love sunshine, but ...
- JavaScript正则表达式进阶指南
摘要:正则表达式是程序员的必备技能,想不想多学几招呢? 本文用JavaScript的exec方法来测试正则表达式. 例如,正则表达式**/F.*g/会匹配"以F开头,以g结尾的字符串&quo ...
- <kotlin>基础,杂七杂八(亲测有效)
okhttp class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) ...
- Lesson 17 Always young
Text My aunt Jennifer is an actress. She must be at least thirty-five years old. In spit of this, sh ...
- 斯考特·杨(Scott Young)快速学习方法
上午在网上看到了斯考特·杨(Scott Young)的快速学习方法,感觉很受鼓舞. 现在已经读研究生了,可是发现自己自从上大学以来到现在,发现自己的学习方法有很大的问题. 我是个特别喜欢读书的人,在大 ...
- forever让nodejs应用后台执行
nodejs一般是当成一条用户命令执行的,当用户断开客户连接,运用也就停了,很烦人.如何让nodejs应用当成服务,在后台执行呢? 最简单的办法: $ nohup node app.js & ...
随机推荐
- Hibernate Hql 总结
1.from子句 Hibernate中最简单的查询语句的形式如下: from eg.Cat该子句简单的返回eg.Cat类的所有实例. 通常我们不需要使用类的全限定名, 因为 auto-import(自 ...
- 自然语言19.1_Lemmatizing with NLTK(单词变体还原)
QQ:231469242 欢迎喜欢nltk朋友交流 https://www.pythonprogramming.net/lemmatizing-nltk-tutorial/?completed=/na ...
- zencart分类页产品页去掉url中的id号
最近公司新上的网站被seo指出要修改url,去掉url中产品id.由于我们用的是zencart框架,装了 Ultimate SEO URLs 插件,所以在网上应该有这方面的资料,本文主要参考资料: 原 ...
- 【Delphi】获取EIP
var EIP: Cardinal; procedure GetEIP(); stdcall; asm pop eax; mov EIP,eax; push eax; end; procedure T ...
- OC-block
#import <Foundation/Foundation.h> /* block要掌握的东西 1> 如何定义block变量 int (^sumBlock)(int, int); ...
- python 文件包含
Python的import包含文件功能就跟PHP的include类似,但更确切的说应该更像是PHP中的require,因为Python里的import只要目标不存在就报错程序无法往下执行.要包含目录里 ...
- ngrok内网穿透利器在windws下的使用
1.到官网下载windows版本:https://ngrok.com/download 2.解压,双击“ngrok.exe” 3.输入“ngrok http 80”,会随机给你分配域名.见下图. ng ...
- CDN技术
CDN 是构建在数据网络上的一种分布式的内容分发网. CDN 的作用是采用流媒体服务器集群技术,克服单机系统输出带宽及并发能力不足的缺点,可极大提升系统支持的并发流数目,减少或避免单点失效带来的不良影 ...
- linux下vim更改注释颜色
我linux下默认底色是黑色,字体是绿色,但是注释默认是蓝色,,很不爽...所以要更改注释颜色......以下文章来自转载. from: http://blog.csdn.net/gz109/arti ...
- kafka环境搭建及librdkafka测试
kafka环境搭建及librdkafka测试 (2016-04-05 10:18:25) 一.kafka环境搭建(转自http://kafka.apache.org/documentation.h ...