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 ;
}
 

最新文章

  1. ASM,C数据类型
  2. PHP支付宝接口RSA验证
  3. 《Secrets of the JavaScript Ninja》:JavaScript 之运行时代码
  4. 使用 Async 和 Await 的异步编程
  5. WinAPI——Windows 消息
  6. cf D. Physical Education and Buns
  7. vim删除^M
  8. 最简单的ADABOOST人脸检测程序。COPY执行,前提是你配置OpenCV周围环境
  9. trove,测试,db小解析
  10. 使用(Drawable)资源———AnimationDrawable资源
  11. Linux硬链接和软连接详解
  12. ios 去掉字符串中的空格 和指定的字符
  13. 设计模式NO.3
  14. IOC之Unity的使用详解
  15. linux c tcp p2p
  16. contenOs7
  17. LeetCode算法题-Pascal&#39;s Triangle II(Java实现)
  18. JQuery Mobile - 动态修改select选择框的选中项
  19. C 共享内存封装
  20. 【Visual Studio】报错SignTool Error: No certificates were found that met all the given criteria.

热门文章

  1. JAVA Socket编程(一)之UDP通信
  2. 深谈auto变量
  3. webpack 理解
  4. bzoj 3142: [Hnoi2013]数列
  5. mysql case when group by实例
  6. SQL企业级面试题
  7. Effective Java 第三版——12. 始终重写 toString 方法
  8. MySQL如何找到表与表之间的关系?
  9. Ubuntu 16.04 升级 PHP 版本至 7.1
  10. Oracle重做日志恢复数据模拟实验