2017-08-31 16:48:00

writer:pprp

这个题比较容易,我用的是快速幂

写了一次就过了

题目如下:

A Math Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description
You are given a positive integer n, please count how many positive integers k satisfy k ^ k <= n
Input
There are no more than 50 test cases.

Each case only contains a positivse integer n in a line.

1≤n≤10^18

Output
For each test case, output an integer indicates the number of positive integers k satisfy k^k≤n in a line. 
Sample Input
1
Sample Output
1
2

Input

There are no more than 50 test cases.

Each case only contains a positivse integer n in a line.

1≤n≤10^18

 
题目分析:
给你一个n,问你最大的 k ^ k <= n的 k的值,你可以用电脑上自带的计算器算一算,大概范围15^15就已经超过18位了,所以可以从15开始倒着枚举
 
代码如下:
#include <iostream>

using namespace std;
typedef long long ll; //a ^ a
__int64 POW(ll a)
{
__int64 result = ;
ll base = a;
ll tmp = a;
while(tmp > )
{
if((tmp & ) == )
result = result * base;
base = base * base;
tmp >>= ;
}
return result;
} //int main()
//{
// ll a;
// cin >> a;
// cout << POW(a) << endl;
//
// return 0;
//} int main()
{
ios::sync_with_stdio(false);
__int64 n;
while(cin >> n)
{
for(int i = ; i >= ; i--)
{
if(POW(i) <= n)
{
cout << i << endl;
break;
}
}
}
return ;
}

最新文章

  1. tomcat 8在win8.1中的配置
  2. java提高篇(二)-----理解java的三大特性之继承
  3. android NDK 生成so 文件流程-ecplice
  4. Redis总结(三)Redis 的主从复制
  5. ibatis XML标签的含义
  6. asp.net中使用ueditor
  7. C#中的yield return与Unity中的Coroutine(协程)(上)
  8. jstl表达式替换某些字符
  9. POJ 3114 Countries in War(强联通分量+Tarjan)
  10. Can’t find file mysql/host.frm
  11. java SecurityManager
  12. Ext JS学习第四天 我们所熟悉的javascript(三)
  13. Windows编程坐标系统概念
  14. javascript 面向对象基础 (1)
  15. 《java入门第一季》之面向对象面试题(面向对象都做了哪些事情)
  16. Docker部署Nginx并修改配置文件
  17. Request获取客户端IP
  18. 逆袭之旅DAY.XIA.Object中常用方法
  19. FireDac 组件说明二
  20. [图解tensorflow源码] 入门准备工作附常用的矩阵计算工具[转]

热门文章

  1. nodejs(二)
  2. 多线程入门-第四章-线程的调度与控制之sleep
  3. 网络编程 - socket通信/粘包/文件传输/udp - 总结
  4. js 获取Array数组 最大值 最小值
  5. 如何缩减手游app安装包的大小?
  6. HTML容易遗忘内容(三)
  7. 随堂小测app(nabcd)
  8. 工作笔记——js与文件上传下载
  9. To keep up-to-date with Latest Jordans 2016
  10. 怎么创建Porlet项目