hdu 5752 Sqrt Bo

Sqrt Bo

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

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
 
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
using namespace std;
int main()
{ string s6="";
string s5="";
string s4="";
string s3="";
string s2="";
string s1="";
string a;
while(cin>>a)
{
if((a.length()==s6.length()&&a>=s6)||(a.length()>s6.length()))
{
printf("TAT\n");
}
else if((a.length()==s5.length()&&a>=s5)||(a.length()>s5.length())){printf("5\n");}
else if((a.length()==s4.length()&&a>=s4)||(a.length()>s4.length())){printf("4\n");}
else if((a.length()==s3.length()&&a>=s3)||(a.length()>s3.length())){printf("3\n");}
else if((a.length()==s2.length()&&a>=s2)||(a.length()>s2.length())){printf("2\n");}
else if((a.length()==s1.length()&&a>=s1)||(a.length()>s1.length())){printf("1\n");}
else if(a=="") printf("0\n");
else if(a=="") printf("TAT\n");
}
return ; }
上一篇:C# 爬虫DLL文件 学习网站


下一篇:HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场