首页 > 代码库 > luogu P2759 奇怪的函数 二分答案+数论
luogu P2759 奇怪的函数 二分答案+数论
题目描述
使得 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 奇怪的函数 二分答案+数论
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。