HDU 5752Sqrt Bo
Sqrt Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 145 Accepted Submission(s): 72
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.
Each test case contains a non-negative integer n(n<10100).
233333333333333333333333333333333333333333333333333333333
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的更多相关文章
- HDU 5762Teacher Bo
Teacher Bo Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tota ...
- HDU 5753Permutation Bo
Permutation Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- hdu Swipe Bo(bfs+状态压缩)错了多次的题
Swipe Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 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 5753 Permutation Bo (推导 or 打表找规律)
Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- HDU 5762 Teacher Bo (暴力)
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- HDU 5754 Life Winner Bo (博弈)
Life Winner Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life W ...
- HDU 5752 Sqrt Bo【枚举,大水题】
Sqrt Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- hdu 5761 Rower Bo 物理题
Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...
随机推荐
- 数据库insert update select语句
http://database.51cto.com/art/200903/113939_1.htm (更新语句) http://blog.csdn.net/chan ...
- Shrio Demo
package com.atguigu.shiro.helloworld; import org.apache.shiro.SecurityUtils; import org.apache.shiro ...
- HDU 5024
题目大意: 在2个图上显示为'.'的位置建两座房间,保证这两间房子中间只转一个90度的弯,可以斜着走,问能建成房子的最远的路程长度为多少 暴力枚举 因为有8个方向,但横竖走和斜着走是不会产生90度角的 ...
- AtCoder Grand Contest 012 D Colorful Balls
题意: 有N个球排成一行,第i个球颜色为ci, 权为wi, 如果两个同色球权值和 <= X 则它们可以交换: 如果两个异色球权值和 <= Y 则它们可以交换:不限制交换次数,求能到达的颜色 ...
- 选择器的使用(root选择器)
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta ...
- Redis Cluster集群搭建后,客户端的连接研究(Spring/Jedis)(待实践)
说明:无论是否已经搭建好集群,还是使用什么样的客户端去连接,都是必须把全部IP列表集成进去,然后随机往其中一个IP写. 这样做的好处: 1.随机IP写入之后,Redis Cluster代理层会自动根据 ...
- Servlet中操作数据库
以下内容引用自http://wiki.jikexueyuan.com/project/servlet/database-access.html: 前提先新建数据库及插入模拟数据: create tab ...
- 英特尔固态盘 说明书PDF
http://www.intel.cn/content/www/cn/zh/solid-state-drives/solid-state-drives-ssd.html
- 学习swift从青铜到王者之Swift集合数据类型03
1 数组的定义 var array1 = [,,,] var array2: Array = [,,,] var array3: Array<Int> = [,,,] var array4 ...
- dubbo服务的group和version
group 当一个接口有多种实现时,可以用group区分 <!-- dubbo group 使用示例 --> <bean id="demoA" class=&qu ...