Sqrt Bo

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 145    Accepted Submission(s): 72

Problem 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
 
直接java暴力
import java.math.*;
import java.util.*;
public class Main{ /**
* @param args
*/
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
BigDecimal n;
BigDecimal tmp=new BigDecimal("10");
BigDecimal tmpp=new BigDecimal("0");
MathContext mc = new MathContext(1000,RoundingMode.HALF_DOWN);
int ans;
while(cin.hasNext()){
ans=-1;
n=cin.nextBigDecimal();
if(n.compareTo(tmpp)==0){
System.out.println("TAT");continue;
}
for(int j=1;j<=5;j++){
BigDecimal d = new BigDecimal(Math.sqrt(n.doubleValue()),mc);
n=d;
if(n.compareTo(tmp)<0){
if(n.intValue()==1){
ans=j;break;
}
}
}
if(ans!=-1)System.out.println(ans);
else System.out.println("TAT");
}
} }

HDU 5752Sqrt Bo的更多相关文章

  1. HDU 5762Teacher Bo

    Teacher Bo Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tota ...

  2. HDU 5753Permutation Bo

    Permutation Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  3. hdu Swipe Bo(bfs+状态压缩)错了多次的题

    Swipe Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  4. HDU 5752 Sqrt Bo (数论)

    Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f ...

  5. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  6. HDU 5762 Teacher Bo (暴力)

    Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...

  7. HDU 5754 Life Winner Bo (博弈)

    Life Winner Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life W ...

  8. HDU 5752 Sqrt Bo【枚举,大水题】

    Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total S ...

  9. hdu 5761 Rower Bo 物理题

    Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...

随机推荐

  1. 洛谷——P2613 【模板】有理数取余

    P2613 [模板]有理数取余 读入优化预处理 $\frac {a}{b}\mod 19620817$ 也就是$a\times b^{-1}$ $a\times b^{-1}\mod 19620817 ...

  2. 「 HDU 1978 」 How many ways

    # 解题思路 记忆化搜索 一个点可以跳到的点,取决于它现在的能量.而且有一个显而易见的性质就是一条可行路径的终点和起点的横坐标之差加上纵坐标之差肯定小于等于起点的能量. 因为跳到一个点之后,能量和之前 ...

  3. 模板BSGS(SDOI2011计算器) 模板EXBSGS

    BSGS和EXBSGS是OI中用于解决A^xΞB(mod C)的常用算法. 1.BSGS BSGS用于A,C互质的情况. 令m=sqrt(C),此时x可表示为i*m+j. 式中i和j都<=sqr ...

  4. squid正向代理使用

     环境: Squid Cache: Version 3.5.20 操作系统: centos7.6 squid安装配置 yum install -y squid systemctl  start  sq ...

  5. js ajax 传送xml dom对象到服务器

    客户端代码 1 <script> var isie = true; var xmlhttp = null; function createXMLHTTP() {//创建XMLXMLHttp ...

  6. C++——"%"运算符

    基本介绍 r=a%b,余数的取值范围为-b+1~b-1,符号与a一致 要想得到0~b-1的余数,可以用:(a%b+b)%b 数位拆解 方法一:反复的:%10,/10 sizea = 0; while ...

  7. BNUOJ 26229 Red/Blue Spanning Tree

    Red/Blue Spanning Tree Time Limit: 2000ms Memory Limit: 131072KB This problem will be judged on HDU. ...

  8. HDU 4944

    FSF’s game Problem Description FSF has programmed a game.In this game, players need to divide a rect ...

  9. Floyd算法——保存路径——输出路径 HDU1385

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1385 参考 http://blog.csdn.net/shuangde800/article/deta ...

  10. codeforces Gym 100735 D、E、G、H、I

    http://codeforces.com/gym/100735 D题 直接暴力枚举 感觉这道题数据有点问题 为什么要先排下序才能过?不懂.. #include <stdio.h> #in ...