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. 数据库insert update select语句

    http://database.51cto.com/art/200903/113939_1.htm                   (更新语句) http://blog.csdn.net/chan ...

  2. Shrio Demo

    package com.atguigu.shiro.helloworld; import org.apache.shiro.SecurityUtils; import org.apache.shiro ...

  3. HDU 5024

    题目大意: 在2个图上显示为'.'的位置建两座房间,保证这两间房子中间只转一个90度的弯,可以斜着走,问能建成房子的最远的路程长度为多少 暴力枚举 因为有8个方向,但横竖走和斜着走是不会产生90度角的 ...

  4. AtCoder Grand Contest 012 D Colorful Balls

    题意: 有N个球排成一行,第i个球颜色为ci, 权为wi, 如果两个同色球权值和 <= X 则它们可以交换: 如果两个异色球权值和 <= Y 则它们可以交换:不限制交换次数,求能到达的颜色 ...

  5. 选择器的使用(root选择器)

    <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta ...

  6. Redis Cluster集群搭建后,客户端的连接研究(Spring/Jedis)(待实践)

    说明:无论是否已经搭建好集群,还是使用什么样的客户端去连接,都是必须把全部IP列表集成进去,然后随机往其中一个IP写. 这样做的好处: 1.随机IP写入之后,Redis Cluster代理层会自动根据 ...

  7. Servlet中操作数据库

    以下内容引用自http://wiki.jikexueyuan.com/project/servlet/database-access.html: 前提先新建数据库及插入模拟数据: create tab ...

  8. 英特尔固态盘 说明书PDF

    http://www.intel.cn/content/www/cn/zh/solid-state-drives/solid-state-drives-ssd.html

  9. 学习swift从青铜到王者之Swift集合数据类型03

    1 数组的定义 var array1 = [,,,] var array2: Array = [,,,] var array3: Array<Int> = [,,,] var array4 ...

  10. dubbo服务的group和version

    group 当一个接口有多种实现时,可以用group区分 <!-- dubbo group 使用示例 --> <bean id="demoA" class=&qu ...