首页 > 其他 > 详细

luogu P2759 奇怪的函数 二分答案+数论

时间:2017-07-01 20:39:51      阅读:327      评论:0      收藏:0      [点我收藏+]

题目描述

使得 x^x 达到或超过 n 位数字的最小正整数 x 是多少?

输入输出格式

输入格式:

 

一个正整数 n

 

输出格式:

 

使得 x^x 达到 n 位数字的最小正整数 x

 

输入输出样例

输入样例#1:
11
输出样例#1:
10

说明

n<=2000000000

 

判断位数important

#include<iostream>
#include<cmath>

using namespace std;

int n;

bool can(int x) 
{
    if(x*(log(x)/log(10))>=n-1)return true;//判断方程
    return false;
}

int findx(int x,int y) 
{ //判断能不能行二分
    int mid=x+(y-x)/2;
    if(y-x<=1)return y;
    if(can(mid))return findx(x,mid);
    return findx(mid,y);
}

int main() 
{
    cin>>n;
    int ans=findx(0,1000000000);
    cout<<ans;//用二分查找实现
    return 0;
}

 

luogu P2759 奇怪的函数 二分答案+数论

原文:http://www.cnblogs.com/lyqlyq/p/7103324.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!