Sqrt Bo

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

Problem Description
Let's define the function $f(n)=\lfloor \sqrt{n}\rfloor$.

Bo wanted to know the minimum number $y$ which satisfies $f^y(n)=1$.

note:$f^1(n)=f(n),f^y(n)=f(f^{y-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<10^{100})$.

 
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
 
Source
 
Recommend
wange2014
 题意:给你一个数 问你需要不断开根多少次结果等于1 超过5次输出 TAT
 
 题解:由于有5次的这个限制,所以尝试寻找分界点。

很容易发现是2^{32},所以我们先比较输入的数字是否比这个大,然后再暴力开根

 
  1. /******************************
  2. code by drizzle
  3. blog: www.cnblogs.com/hsd-/
  4. ^ ^ ^ ^
  5. O O
  6. ******************************/
  7. //#include<bits/stdc++.h>
  8. #include<iostream>
  9. #include<cstring>
  10. #include<cmath>
  11. #include<cstdio>
  12. #define ll long long
  13. #define mod 1000000007
  14. #define PI acos(-1.0)
  15. using namespace std;
  16. char a[];
  17. ll ans;
  18. int main()
  19. {
  20. while(scanf("%s",a)!=EOF){
  21. ans=;
  22. int len=strlen(a);
  23. if(len>||(len==&&a[]==''))
  24. printf("TAT\n");
  25. else
  26. {
  27. for(int i=;i<len;i++)
  28. ans=ans*+a[i]-'';
  29. int jishu=;
  30. while()
  31. {
  32. jishu++;
  33. double exm=ans;
  34. exm=sqrt(exm);
  35. ans=(ll)exm;
  36. if(ans==)
  37. break;
  38. }
  39. if(jishu<=)
  40. printf("%d\n",jishu);
  41. else
  42. printf("TAT\n");
  43. }
  44. }
  45. return ;
  46. }

HDU 5752的更多相关文章

  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

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

  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 水题

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

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

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

  6. hdu 5752 Sqrt Bo

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

  7. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  8. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  9. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

随机推荐

  1. nginx配置安装

    先安装pcrepcre作用是让Nginx支持Rewrite功能下载地址:https://sourceforge.net/projects/pcre/files/pcre/,选择最新版本进行下载下载之后 ...

  2. scrapy--ipproxy

    不要急于求成,你只要做的是比昨天的你更优秀一点 --匿名 今天给大家讲一下--IpProxy,由于从"http://www.xicidaili.com/nn"爬取,以下是我转载的博 ...

  3. 【Python 2 到 3 系列】 此整型非彼整型

    v2.2 (2.x)以后,python支持不会溢出的 long 型. v3.0后,确切的讲, int 型(依赖运行环境C编译器中long型的精度)消失了,long型替代 int 型,成为新的.不依赖运 ...

  4. 虚拟机桥接模式下多台Ubuntu16.04系统互相连接

    1.首先新建一个虚拟机并在该虚拟机上安装Ubuntu16.04系统.为这台虚拟机起名为Ubuntu3. 2.对Ubuntu3进行克隆,为新克隆生成的虚拟机起名为Ubuntu2.(这时我们会发现Ubun ...

  5. python-2函数

    http://docs.python.org/3/library/functions.html 或者菜鸟中文资料 1-使用函数 abs(-20)#求绝对值 max(1,4,200,3,2) #求最大的 ...

  6. 笔记-scrapy-cookie

    笔记-scrapy-cookie传递 1.      scrapy cookie传递 1.1.    开始 与cookie相关的设置参数有两个: COOKIES_ENABLED 决定是否使用cooki ...

  7. Java石头剪刀布小游戏

    package com.neusoft.test; import java.awt.BorderLayout; import java.awt.Choice; import java.awt.Colo ...

  8. WPF系列教程——(三)使用Win10 Edge浏览器内核 - 简书

    原文:WPF系列教程--(三)使用Win10 Edge浏览器内核 - 简书 在需要显示一些 H5网站的时候自带的WebBrowser总是显示不了,WebBrowser使用的是IE内核,许多H5新特性都 ...

  9. 绿盟python测试实习面试

    1.简历问题 低级错误:时间写错 最近好像越来越马大哈了,总是犯低级错误. 上次的开题报告首页,这次的时间,每次都有小问题,确是大毛病 到底哪里出错了 2 RHCE证书好像没有用 面试官根本就不懂这个 ...

  10. laravel5.5用户认证

    目录 1. 命令 2. 快速认证 2.1 自定义路径 2.2 自定义用户名 2.3 自定义看守器 2.4 自定义验证/存储 2.5 Auth::xx() 2.6 保护路由 2.7 指定看守器 3 手动 ...