首页 技术 正文
技术 2022年11月16日
0 收藏 397 点赞 4,113 浏览 1368 个字

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;

}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898