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 ...
随机推荐
- bzoj千题计划222:bzoj2329: [HNOI2011]括号修复(fhq treap)
http://www.lydsy.com/JudgeOnline/problem.php?id=2329 需要改变的括号序列一定长这样 :)))((( 最少改变次数= 多余的‘)’/2 [上取整] + ...
- 第一次使用 markdown 写博客
Web前端 js 框架(四选一) 有可能的话,学 Vue.js ,React.js ,Angular.js,Awrelia css 学习 Sass 学会 css 的可编程 HTML5 详细语法 Nod ...
- dedecms列表页调用文章正文内容的方法
谁说dede:list 标签不能调用body内容,现在就告诉你,直接就可以调用 第一步,打开后台 核心-->频道模型-->内容模型管理-->普通文章,在列表附加字段中添加body. ...
- 读asyncio模块源码时的知识补漏
硬着头皮看了一周的asyncio模块代码,了解了大概的执行流程,引用太多,成尤其是对象间函数的引用. 光是这么一段简单的代码: # coding: utf8 import asyncio import ...
- 20155218 2016-2017-2 《Java程序设计》第7周学习总结
20155218 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 就目前来说,即使标注为GMT(无论是文件说明,或者是API的日期时间字符串描述),实际上谈到 ...
- Linux - awk 文本处理工具二
awk 判断格式 awk '{print ($1>$2)?"第一排"$1:"第二排"$2}' # 条件判断 括号代表if语句判断 "?" ...
- 洛谷 P4656: LOJ 2484: [CEOI2017]Palindromic Partitions
菜菜只能靠写简单字符串哈希维持生活. 题目传送门:LOJ #2484. 题意简述: 题面讲得很清楚了. 题解: 很显然从两边往中间推,能选的就选上这个贪心策略是对的. 如何判断能不能选上,直接字符串哈 ...
- 5 THINGS TOP BUG BOUNTY HUNTERS DO DIFFERENTLY
出处:https://www.hackerone.com/blog/5-things-top-bug-bounty-hunters-do-differently 本周,我们有幸收容了50名比利时科技学 ...
- 编程入门python之定义函数【转】
编程入门python之定义函数 零基础学编程by学哥 2017-02-06 10:51 今天讲python函数. 输入参数求三角形或圆形或长方形的面积 先输入1个参数:形状类型 1=三角形 2=圆形 ...
- 百度url解析Joe.Smith整理大全
百度url解析Joe.Smith整理大全 百度url解析Joe.Smith整理大全...1 本文链接:http://blog.csdn.net/qq_26816591/article/details/ ...