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 ...
随机推荐
- python各种推导式分析
推导式comprehensions(又称解析式),是Python的一种独有特性.推导式是可以从一个数据序列构建另一个新的数据序列的结构体. 共有三种推导,在Python2和3中都有支持: 列表(lis ...
- Why Countries Succeed and Fail Economically
Countries Succeed and Fail Economically(第一部分)" title="Why Countries Succeed and Fail Econo ...
- java字符串利用正则表达式分割
平时用到,整理的,总感觉缺点什么: private String getKeywordByContent(String content) { StringBuffer sbAllKwyword = n ...
- java读utf8 的txt文件,第一个字符为空或问号问题
参考:https://blog.csdn.net/yangzhichao888/article/details/79529756 https://blog.csdn.net/wangzhi291/ar ...
- Webdriver概述(selenium对应浏览器版本)
Webdriver (Selenium2)是一种用于Web应用程序的自动测试工具,它提供了一套友好的API,与Selenium 1(Selenium-RC)相比,Webdriver 的API更容易理解 ...
- SPOJ ARCTAN
POJ1183 除输入方式外与这道题完全一样 题目大意是给定一个a 求最小的满足arctan(1/A)=arctan(1/B)+arctan(1/C) 的B+C的最小值 根据上述递推规律,我们只要从2 ...
- hdu 4771好题
#include<stdio.h> #include<string.h>//通过只记录每一步此时点的状态.题非常好 #include<queue> using na ...
- [NOIP2007] 提高组 洛谷P1005 矩阵取数游戏
题目描述 帅帅经常跟同学玩一个矩阵取数游戏:对于一个给定的n*m的矩阵,矩阵中的每个元素aij均为非负整数.游戏规则如下: 1.每次取数时须从每行各取走一个元素,共n个.m次后取完矩阵所有元素: 2. ...
- 解决Android Studio2.0不能使用HttpClient
在build.gradle中的android {}中加上useLibrary 'org.apache.http.legacy'
- ****HTML模板资源汇总
站长素材: http://sc.chinaz.com/tag_moban/HTML.html wordpress模板: http://www.cssmoban.com/wpthemes/ http:/ ...