Sqrt Bo

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

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
 
Author
绍兴一中
 
Source
题意:给你一个数,对这个数进行连续开方,这个数能在5次以内开方(每次开方都是向下取整),使得最后结果等于1,输出开方次数,否则输出TAT
分析:看起来这道题怪吓人的,10^100次,lfh跟我说这道题很难,要用字符串啥玩意来着,然后算什么2^32的数还是啥的,弱弱菜鸡就随手扔了一个代码
枚举一波连续开5次根的数,然后。。。。竟然AC了,旁边的lfh懵逼了:这也行?(弱弱的说他好像Wa了好几发的样子),此题数据是10^100,建议开long double型
其次是。。。。。我特别嫌弃这种要连续输入的题,每次害得我找错误找半天QAQ!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
typedef long double ll;
inline ll gcd(ll x)
{
int k,t;
int flag=;
for(k=;k<=;k++)
{
x=(long long)sqrt(x);
if(x==)
{
flag=;
t=k;
break;
}
}
if(flag)
return t;
return ;
}
int main()
{
ll n;
while(cin>>n)
{
if(!gcd(n))
cout<<"TAT"<<endl;
else cout<<gcd(n)<<endl;
}
return ;
}
 

HDU 5752 Sqrt Bo【枚举,大水题】的更多相关文章

  1. hdu 5752 Sqrt Bo 水题

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

  2. HDU 5752 Sqrt Bo (数论)

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

  3. hdu 5752 Sqrt Bo

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

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

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

  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 4548 美素数 超级大水题

    美素数 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submis ...

  7. POJ 2586 Y2K Accounting Bug(枚举大水题)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10674   Accepted: 53 ...

  8. hdu 5761 Rowe Bo 微分方程

    1010 Rower Bo 首先这个题微分方程强解显然是可以的,但是可以发现如果设参比较巧妙就能得到很方便的做法. 先分解v_1v​1​​, 设船到原点的距离是rr,容易列出方程 \frac{ dr} ...

  9. poj1873 The Fortified Forest 凸包+枚举 水题

    /* poj1873 The Fortified Forest 凸包+枚举 水题 用小树林的木头给小树林围一个围墙 每棵树都有价值 求消耗价值最低的做法,输出被砍伐的树的编号和剩余的木料 若砍伐价值相 ...

随机推荐

  1. UITextFiled的输入框改成一条下划线

    在一些程序的界面中,它们的编辑框是一条线,而UITextFiled本身并没有这种style,所有需要我们自己设置.方法还是挺多的 第一种 , (1).我们可以声明一个类继承与UITextFiled ( ...

  2. 使用SplitContainer来实现隐藏窗口的部分内容(转)

    有两种方法: (1) Splitter:比较老的方法 (2) SplitContainer:比较新的方法 最终界面如下: 方法一:使用Splitter实现 (1) 在窗口中添加一个Panel控件,即P ...

  3. 仿知乎app登录界面(Material Design设计框架拿来就用的TexnInputLayout)

    在我脑子里还没有Material Design这种概念,就我个人而言,PC端应用扁平化设计必须成为首选,手当其冲的两款即时通讯旺旺和QQ早就完成UI扁平化的更新,然而客户端扁平化的设计本身就存在天生的 ...

  4. 如何安装mysql

    如何安装mysql对于初学者来说的确是很麻烦,首先要知道安装mysql仅仅只是安装一个mysql系统,是没有任何可视化操作界面的,所以还要安装一个mysql的管理工具,这是初学者容易蒙的地方之一. m ...

  5. Equilibrium point

    Given an array A your task is to tell at which position the equilibrium first occurs in the array. E ...

  6. vue入坑总结

    1.Do not mount Vue to <html> or <body> - mount to normal elements instead. Vue2.x之后不推荐挂载 ...

  7. go generate 生成代码

    今后一段时间要研究下go generate,在官网博客上看了Rob Pike写的generating code,花了一些时间翻译了下.有几个句子翻译的是否正确有待考量,欢迎指正. 生成代码 通用计算的 ...

  8. Linux发行版 CentOS6.5 禁用防火墙步骤

    本文地址http://comexchan.cnblogs.com/,尊重知识产权,转载请注明出处,谢谢! 注意:此操作需要使用root权限执行 首先查询防火墙状态: service iptables ...

  9. 部署github开源软件遇到的问题

    jdk1.8源版本不一样: 将语言级别改为8,所有的jdk都配置为1.8 2. 遇到一些解析错误 应该是tomcat的jdk版本和项目的jdk版本不一样

  10. redis实现分布式可重入锁

    利用redis可以实现分布式锁,demo如下: /** * 保存每个线程独有的token */ private static ThreadLocal<String> tokenMap = ...