hdu 5752 Sqrt Bo 水题
Sqrt Bo
题目连接:
http://acm.hdu.edu.cn/showproblem.php?pid=5752
Description
Let's define the function f(n)=⌊n−−√⌋.
Bo wanted to know the minimum number y which satisfies fy(n)=1.
note:f1(n)=f(n),fy(n)=f(fy−1(n))
It is a pity that Bo can only use 1 unit of time to calculate this function each time.
And Bo is impatient, he cannot stand waiting for longer than 5 units of time.
So Bo wants to know if he can solve this problem in 5 units of time.
Input
This problem has multi test cases(no more than 120).
Each test case contains a non-negative integer n(n<10100).
Output
For each test case print a integer - the answer y or a string "TAT" - Bo can't solve this problem.
Sample Input
233
233333333333333333333333333333333333333333333333333333333
Sample Output
3
TAT
Hint
题意
给你一个数,问你最少开多少次,可以变成1。
如果超过五次还没有变成1,就输出TAT
题解:
象征性猜一猜,五次的根号不会很大。
1->3->15->255->65535->4294967295
那就最大就是4294967295了,超过就直接输出TAT好了
代码
#include<bits/stdc++.h>
using namespace std;
string s;
void solve(){
if(s.size()>18){
printf("TAT\n");
return;
}
long long n = 0;
for(int i=0;i<s.size();i++){
n = n*10+s[i]-'0';
}
if(n==1){
cout<<"0"<<endl;
return;
}
for(int i=1;i<=5;i++){
n = sqrt(n);
if(n==1){
cout<<i<<endl;
return;
}
}
cout<<"TAT"<<endl;
}
int main(){
while(cin>>s)solve();
return 0;
}
hdu 5752 Sqrt Bo 水题的更多相关文章
- HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场
题目:传送门. 题意:一个很大的数n,最多开5次根号,问开几次根号可以得到1,如果5次还不能得到1就输出TAT. 题解:打表题,x1=1,x2=(x1+1)*(x1+1)-1,以此类推.x5是不超过l ...
- HDU 5752 Sqrt Bo【枚举,大水题】
Sqrt Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- HDU 5752 Sqrt Bo (数论)
Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f ...
- hdu 5752 Sqrt Bo
Sqrt Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- 【模拟】HDU 5752 Sqrt Bo
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 题目大意: 定义f(n)=⌊√n⌋,fy(n)=f(fy-1(n)),求y使得fy(n)=1. ...
- hdu 5753 Permutation Bo 水题
Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- Sqrt Bo (水题)
#include<bits/stdc++.h> using namespace std; ], comp; ]; int main(){ arr[] = 1LL; ; i < ; i ...
- hdu 1106:排序(水题,字符串处理 + 排序)
排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- HDU 4950 Monster (水题)
Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...
随机推荐
- 【转载】视频CDN技术原理与流程说明
视频CDN专为移动互联网视频内容分发量身定做的一套自主研发的分布式平台,该平台以深圳为中心,分布在全国各地BGP机房的服务器为边缘节点,汇聚中国电信.中国联通.中国移动.中国教育网等运营商网络资源,构 ...
- HTML5 JavaScript实现图片文字识别与提取
8月底的时候,@阿里巴巴 推出了一款名为“拯救斯诺克”的闯关游戏,作为前端校园招聘的热身,做的相当不错,让我非常喜欢.后来又传出了一条消息,阿里推出了A-star(阿里星)计划,入职阿里的技术培训生, ...
- Web性能优化系列(1):Web性能优化分析
本文由 伯乐在线 - 鸭梨山大 翻译,sunbiaobiao 校稿.未经许可,禁止转载!英文出处:gokulkrishh.github.io.欢迎加入翻译小组. 如果你的网站在1000ms内加载完成, ...
- A*算法改进——Any-Angle Path Planning的Theta*算法与Lazy Theta*算法
本文是该篇文章的归纳http://aigamedev.com/open/tutorial/lazy-theta-star/#Nash:07 . 传统的A*算法中,寻找出来的路径只能是沿着给出的模型(比 ...
- pt-table-checksum 3.0.4检测不出主从差异数据
群里好几位同学问 pt-table-checksum 3.0.4, 主从两个表数据是不一致,为啥检测不出来?前段时间自己也测试过,只是没整理成随笔^_- 一.基本环境 VMware10.0+CentO ...
- Linux awk工具简单学习记录
awk是一个文本分析工具,它把文件逐行读入,以特定符号将每行切分(默认空格为分隔符),切开的部分再进行各种分析处理. awk其名称得自于它的创始人Alfred Aho .Peter Weinberge ...
- 如何使用jpegtran 压缩JPG图片
说到jpegtran相信很多人都比较陌生,网上相关的资料也很少. jpegtran可以让图片更加的简化,缩小图片的容量,从而增加网络的传输速度.说在多你也不信,下面就让事实证明. 首先下载 jpeg ...
- pip2和pip3冲突问题解决方法
python使用pip安装模块时报错:unable to create process using ' '的解决方法: 参考:http://qoogle.cn/?id=39 1.删除C:\Python ...
- ajax与302响应
在ajax请求中,如果服务器端的响应是302 Found,在ajax的回调函数中能够获取这个状态码吗?能够从Response Headers中得到Location的值进行重定向吗?让我们来一起看看实际 ...
- metasploit利用漏洞渗透攻击靶机
1.网络测试环境构建 首先需要先配置好一个渗透测试用的网络环境,包括如图1所示的运行Kali Linux系统的计算机,如图2所示的老师给的Windows Server 2000系统的计算机.这两台计算 ...