码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 5752 Sqrt Bo

时间:2016-07-31 11:25:44      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

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(fy1(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="4294967296";
    string s5="65536";
    string s4="256";
    string s3="16";
    string s2="4";
    string s1="2";
    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=="1") printf("0\n");
        else if(a=="0") printf("TAT\n");
    }
    return 0;


}
View Code

 

hdu 5752 Sqrt Bo

标签:

原文地址:http://www.cnblogs.com/superxuezhazha/p/5722464.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!