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

Hint

题意

给你一个数,问你最少开多少次,可以变成1。

如果超过五次还没有变成1,就输出TAT

题解:

象征性猜一猜,五次的根号不会很大。

1->3->15->255->65535->4294967295

那就最大就是4294967295了,超过就直接输出TAT好了

代码

#include<bits/stdc++.h>
using namespace std;
string s;
void solve(){
if(s.size()>18){
printf("TAT\n");
return;
}
long long n = 0;
for(int i=0;i<s.size();i++){
n = n*10+s[i]-'0';
}
if(n==1){
cout<<"0"<<endl;
return;
}
for(int i=1;i<=5;i++){
n = sqrt(n);
if(n==1){
cout<<i<<endl;
return;
}
}
cout<<"TAT"<<endl;
}
int main(){ while(cin>>s)solve();
return 0; }

hdu 5752 Sqrt Bo 水题的更多相关文章

  1. HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场

    题目:传送门. 题意:一个很大的数n,最多开5次根号,问开几次根号可以得到1,如果5次还不能得到1就输出TAT. 题解:打表题,x1=1,x2=(x1+1)*(x1+1)-1,以此类推.x5是不超过l ...

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

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

  3. HDU 5752 Sqrt Bo (数论)

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

  4. hdu 5752 Sqrt Bo

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

  5. 【模拟】HDU 5752 Sqrt Bo

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 题目大意: 定义f(n)=⌊√n⌋,fy(n)=f(fy-1(n)),求y使得fy(n)=1. ...

  6. hdu 5753 Permutation Bo 水题

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

  7. Sqrt Bo (水题)

    #include<bits/stdc++.h> using namespace std; ], comp; ]; int main(){ arr[] = 1LL; ; i < ; i ...

  8. hdu 1106:排序(水题,字符串处理 + 排序)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  9. HDU 4950 Monster (水题)

    Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...

随机推荐

  1. poj 3686 Priest John's Busiest Day

    http://poj.org/problem?id=3683 2-sat 问题判定,输出一组可行解 http://www.cnblogs.com/TheRoadToTheGold/p/8436948. ...

  2. 转----MarkdownPad2.5 注册码

    经测试可用 User: Soar360@live.com 授权: GBPduHjWfJU1mZqcPM3BikjYKF6xKhlKIys3i1MU2eJHqWGImDHzWdD6xhMNLGVpbP2 ...

  3. 控制台console对象常用的一些方法

    console.log():调试中最常用的方法,用于在控制台窗口显示信息. console.log(123); console.warn():输出信息时,在最前面加一个黄色三角,表示警告 consol ...

  4. ReactJS -- 初学入门

    <!DOCTYPE html> <html> <head> <script src="build/react.js"></sc ...

  5. Unable to Distribute in Xcode5?

    Blog Unable to Distribute in Xcode5? I have the  question, if this screenshot is what you getting. ( ...

  6. ssh-copy-id 复制公钥到远程server

    ssh-copy-id -i ~/.ssh/mykey.pub user@host 复制完成后可以测试: ssh -i ~/.ssh/mykey user@host

  7. Java反射--基于ParameterizedType实现泛型类,参数化类型

    一.引子: 项目中使用Gson的反序列化将json转化成具体的对象,具体方法是: package com.google.gson;下的反序列化方法 public <T> T fromJso ...

  8. DVWA的Xss跨站总结

    Xss跨站总结 初级防护的代码 Poc:<script>alert(1)</script> 上图防护的代码 为输入的结果就为输出的结果 中级防护的代码 Poc:<scri ...

  9. linux下如何模拟按键输入和模拟鼠标【转】

    转自:http://www.cnblogs.com/leaven/archive/2010/11/30/1891947.html 查看/dev/input/eventX是什么类型的事件, cat /p ...

  10. Android 6.0 API

    Android 6.0 (M) 为用户和应用开发者提供了新功能.本文旨在介绍其中最值得关注的 API. 着手开发 要着手开发 Android 6.0 应用,您必须先获得 Android SDK,然后使 ...