hdu5752——Sqrt Bo(水)

来源:互联网 发布:oc第三方网络请求 编辑:程序博客网 时间:2024/05/21 09:51

Problem Description
Let’s define the function .

Bo wanted to know the minimum number which satisfies .

note:

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 ).

Each test case contains a non-negative integer .

Output
For each test case print a integer - the answer or a string “TAT” - Bo can’t solve this problem.

Sample Input
233
233333333333333333333333333333333333333333333333333333333

Sample Output
3
TAT

超过5次就不行,所以临界值是2^32,就输出TAT。我一开始没把2^32本身算进去,死命WA。。。

#include <iostream>#include <cstring>#include <string>#include <vector>#include <queue>#include <cstdio>#include <map>#include <cmath>#include <algorithm>#define INF 0x3f3f3f3f#define MAXN 100010#define mod 1000000007using namespace std;char s[105];int main(){    while(scanf("%s",s)==1)    {        if(strlen(s)>10)        {            printf("TAT\n");            continue;        }        long long num;        sscanf(s,"%I64d",&num);        if(num==0||num>=4294967296)        {            printf("TAT\n");        }        else        {            for(long long i=0,e=2;i<=5;e=e*e,++i)            {                if(num<e)                {                    printf("%I64d\n",i);                    break;                }            }        }    }    return 0;}
0 0