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
Source
2016 Multi-University Training Contest 3
##题意: 给出一个数(1e100),问能否在开5次平方以内收敛到1. 若能则输出次数,否则输出TAT.
##题解: 首先找一个边界:恰好开5次平方不能到1的.很容易找出是2^32. 由于输入数据很大,所以要用字符串读入,长度大于10的串直接输出TAT. 长度合适的串用sscanf读出数据,先与2^32比较,再进行开平方操作. 要注意0的情况:0输出TAT.
##代码: ``` cpp #include