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的更多相关文章

  1. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  2. Java:网络编程

    一.因特网地址 InetAddress类:实现主机名和因特网地址之间的转换. InetAddress address=InetAddress.getByName(String);返回一个InetAdd ...

  3. 2017人生总结(MECE分析法)

    试着用MECE分析法对人生的整个规划做一下总结.作为技术人员,其实除了编码架构能力之外,分析问题的能力的重要程度也会随着职业发展越来越重要.<美团点评技术博客>说这几天要在黄金时段头版头条 ...

  4. November 08th, 2017 Week 45th Wednesday

    Keep your face to the sunshine and you cannot see the shadow. 始终面朝阳光,我们就不会看到黑暗. I love sunshine, but ...

  5. JavaScript正则表达式进阶指南

    摘要:正则表达式是程序员的必备技能,想不想多学几招呢? 本文用JavaScript的exec方法来测试正则表达式. 例如,正则表达式**/F.*g/会匹配"以F开头,以g结尾的字符串&quo ...

  6. <kotlin>基础,杂七杂八(亲测有效)

    okhttp class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) ...

  7. 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 ...

  8. 斯考特·杨(Scott Young)快速学习方法

    上午在网上看到了斯考特·杨(Scott Young)的快速学习方法,感觉很受鼓舞. 现在已经读研究生了,可是发现自己自从上大学以来到现在,发现自己的学习方法有很大的问题. 我是个特别喜欢读书的人,在大 ...

  9. forever让nodejs应用后台执行

    nodejs一般是当成一条用户命令执行的,当用户断开客户连接,运用也就停了,很烦人.如何让nodejs应用当成服务,在后台执行呢? 最简单的办法: $ nohup node app.js & ...

随机推荐

  1. sql附加数据库错误5120

    http://zhidao.baidu.com/link?url=p1o8EjUhn-RYFt1D4uIM-5HQF1oXZIRlPGaDiZ2FRMDzZDG1ooSARfkoPWG6SzTJTN6 ...

  2. BZOJ2208: [Jsoi2010]连通数

    tarjan缩点后拓扑排序,每一个点用一个bitset记录哪些点能到达它. PS:数据太水,暴力能过. #include<bits/stdc++.h> using namespace st ...

  3. IOS VFL屏幕自适应

    -(void)fun1{ //注意使用VFL,不用设置视图的frame UIView *view = [[UIView alloc] init]; view.backgroundColor = [UI ...

  4. MFC学习-第2,3课 MFC框架的运行机制

    转自:http://blog.163.com/zhigang0633@126/blog/static/38790491200822711526168/ 讲述MFC AppWizard的原理与MFC程序 ...

  5. centos 查看是32位还是64位

    查看linux机器是32位还是64位的方法: file /sbin/init 或者 file /bin/ls/sbin/init: ELF 64-bit LSB executable, x86-64, ...

  6. JavaScript学习笔记——节点

    javascript-节点属性详解 根据 DOM,HTML 文档中的每个成分都是一个节点. DOM 是这样规定的: 整个文档是一个文档节点 每个 HTML 标签是一个元素节点 包含在 HTML 元素中 ...

  7. (转)HBase 的原理和设计

    转自:HBase的原理和设计 HBase架构:

  8. 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【十】——使用CacheCow和ETag缓存资源

    系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 本文将使用一个开源框架CacheCow来实现针对Http请求资源缓存,本文主要介绍服务器端的 ...

  9. Jquery实现textarea根据文本内容自适应高度

    本文给大家分享的是Jquery实现textarea根据文本内容自适应高度,这些在平时的项目中挺实用的,所以抽空封装了一个文本框根据输入内容自适应高度的插件,这里推荐给小伙伴们. autoTextare ...

  10. EasyDarwin

     1.EasyDarwin多媒体点播实现 新版本EasyDarwin都加入了中心管理服务EasyCMS, 对于点播系统,EasyCMS不是必须的. MP4点播,需要将mp4文件hint之后才行,MP4 ...