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

    快速上手http://docs.python-requests.org/zh_CN/latest/user/quickstart.html Requests 是使用 Apache2 Licensed ...

  2. sql附加数据库错误5120

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

  3. BZOJ4527: K-D-Sequence 线段树

    别人家的题解. #include<bits/stdc++.h> #define N 200005 #define M (l+r>>1) #define P (k<< ...

  4. mvc-1

  5. JavaWeb学习笔记——JDOM

    JavaDOC的网址:http://www.jdom.org/docs/apidocs/index.html import java.io.FileOutputStream; import org.j ...

  6. VBO, VAO, Generic Vertex Attribute

    VBO - 用于存储顶点数据的Buffer Object. VAO - 用于组织VBO的对象. Generic Vertex Attribute - 通用顶点属性. For example, the ...

  7. Mastering C# structs

    http://www.developerfusion.com/article/84519/mastering-structs-in-c/

  8. 发现不错的cache系统Cache Manager Documentation

    http://cachemanager.net/Documentation/Index/cachemanager_architecture https://www.nuget.org/packages ...

  9. LSM存储模型

    LSM存储模型 数据库有3种基本的存储引擎: 哈希表,支持增.删.改以及随机读取操作,但不支持顺序扫描,对应的存储系统为key-value存储系统.对于key-value的插入以及查询,哈希表的复杂度 ...

  10. STL删除元素

    1.从vector中删除多个元素: #include <iostream> #include <vector> int main() { std::vector<int& ...