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

Source

2016 Multi-University Training Contest 3

##题意:

给出一个数(1e100),问能否在开5次平方以内收敛到1.
若能则输出次数,否则输出TAT.


##题解:

首先找一个边界:恰好开5次平方不能到1的.很容易找出是2^32.
由于输入数据很大,所以要用字符串读入,长度大于10的串直接输出TAT.
长度合适的串用sscanf读出数据,先与2^32比较,再进行开平方操作.
要注意0的情况:0输出TAT.


##代码:
``` cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define eps 1e-8
#define maxn 700
#define mod 100000007
#define inf 0x3f3f3f3f
#define IN freopen("in.txt","r",stdin);
using namespace std;

char str[120];

int main(int argc, char const *argv[])

{

//IN;

while(scanf("%s", str) != EOF)
{
int len = strlen(str);
if(len > 10) {
printf("TAT\n");
continue;
} LL n = 0;
sscanf(str,"%I64d", &n); LL cmps = 1LL<<32;
if(n >= cmps || !n) {
printf("TAT\n");
continue;
} int cnt = 0;
while(n != 1){
n = sqrt(n);
cnt++;
} printf("%d\n", cnt);
} return 0;

}

HDU 5752 Sqrt Bo (数论)的更多相关文章

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

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

  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

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

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

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

  6. 七夕节 (HDU - 1215) 【简单数论】【找因数】

    七夕节 (HDU - 1215) [简单数论][找因数] 标签: 入门讲座题解 数论 题目描述 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们 ...

  7. HDU 1005 Number Sequence(数论)

    HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, ...

  8. HDU 5752

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

  9. Least Common Multiple (HDU - 1019) 【简单数论】【LCM】【欧几里得辗转相除法】

    Least Common Multiple (HDU - 1019) [简单数论][LCM][欧几里得辗转相除法] 标签: 入门讲座题解 数论 题目描述 The least common multip ...

随机推荐

  1. Android开发之异步通信Handler机制

    郭大神的:http://blog.csdn.net/guolin_blog/article/details/9991569 http://www.jianshu.com/p/08cb3665972f ...

  2. 函数fsp_header_init

    /**********************************************************************//** Initializes the space he ...

  3. 由于管理员设置的策略,该磁盘处于脱机状态-Win 2008 R2

    问题截图: 做了个小说网站www.114369.cn,使用的是云主机,系统是Win 2008 R2,进入服务器后发现磁盘有问题 只有c盘,没有d盘,提示:由于管理员设置的策略,该磁盘处于脱机状态 解决 ...

  4. I.MX6 git patch

    /********************************************************************** * I.MX6 git patch * 说明: * 之前 ...

  5. ti processor sdk linux am335x evm /bin/commom.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/commom.sh hacking # 说明: # 本文主要对TI的sdk中的common.s ...

  6. poj 1392 Ouroboros Snake

    题目描述:咬尾蛇是古埃及神话中一种虚构的蛇.它经常把尾巴放在自己的嘴巴里,不停地吞噬自己.环数类似于咬尾蛇,它是2^n位的二进制数,具有如下性质:它能“生成”0-2^n-1之间的所有数.生成方法是:给 ...

  7. ORACLE CLIENT客户端安装步骤详解

    下载地址: http://download.oracle.com/otn/nt/oracle11g/112010/win32_11gR2_client.zip 先将下载下来的ZIP文件解压,并运行se ...

  8. Tomcat 调优总结

    一. jvm参数调优 常见的生产环境tomcat启动脚本里常见如下的参数,我们依次来解释各个参数意义. export JAVA_OPTS="-server -Xms1400M -Xmx140 ...

  9. Android平台下实现录音及播放录音功能的简介

    录音及播放的方法如下: package com.example.audiorecord; import java.io.File; import java.io.IOException; import ...

  10. 【JS】<c:foreach>用法

    <c:foreach>类似于for和foreach循环   以下是我目前见过的用法: 1.循环遍历,输出所有的元素. <c:foreach items="${list}&q ...