洛谷OJ
来源:互联网 发布:淘宝帐号永久冻结解封 编辑:程序博客网 时间:2024/05/21 10:05
- 题目描述
- 使得 x^x 达到或超过 n 位数字的最小正整数 x 是多少?
- 输入
- 一个正整数 n
- 输出
- 使得 x^x 达到 n 位数字的最小正整数 x
- 样例输入
11
- 样例输出
10
- 题目思路
将题目翻译成公式即为:x^x >= 10^(n-1) 对两边取对数得到 x*log10(x) >= n-1 那么我们只要枚举 x 得到最小的x即可,由于数据量的问题,我们采用二分法快速找到最小的x。
- 题目代码
#include <cstdio> #include <iostream>#include <map>#include <set>#include <vector>#include <stack>#include <cmath>#include <string>#include <cstring>#include <algorithm>#define LL long long using namespace std;int n, x;int l, r, mid;bool check(int a){return a*log10(a) >= n-1;}int main(){while(scanf("%d",&n) != EOF){l = 1; r = 1000000000;while(l < r){mid = (l+r) >> 1;if(check(mid))r = mid;elsel = mid + 1; } printf("%d\n",r);}return 0;}
阅读全文
1 0
- 洛谷OJ
- 洛谷OJ
- 洛谷oj
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- 洛谷OJ
- Linux(Ubuntu)下MySQL的安装与配置
- bzoj1589
- javaSE_8系列博客——Java语言的特性(四)--注解--(2)-- 声明一个注解
- 瑜伽微信微预约在微信公众平台怎么实现
- 静态链接库 & 动态链接库
- 洛谷OJ
- [ROR] 解决N+1问题的心得
- RTTI、反射、动态代理部分知识总结
- node.js结合mongoose对表单进行数据简单的增删改查
- 类和对象的初步接触
- 全新的PRT技术
- MySQL快速修改表结构,只针对更改varchar类型字段长度
- Netroid 无法导入 http.protocol.HTTP问题
- 【hibernate】hibernate配置及实例(sqlsever)