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 thisproblem.
Sample Input 233 233333333333333333333333333333333333333333333333333333333 Sample Output 3 TAT
AC代码:
1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<queue> 5 #include<algorithm> 6 #include<time.h> 7 using namespace std; 8 9 const int maxn = 2005; 10 const int N=100007; 11 12 #define lson rt<<1///rt*2 13 #define rson rt<<1|1///rt*2+1 14 15 char s[N]; 16 17 int main() 18 { 19 int len,i; 20 21 while(scanf("%s", s) != EOF) 22 { 23 long long d=0; 24 len=strlen(s); 25 if(len>10) 26 { 27 printf("TAT "); 28 continue ; 29 } 30 for(i=0; i<len; i++) 31 d=d*10+s[i]-'0'; 32 33 34 if(d>=65536&&d<4294967296) 35 printf("5 "); 36 else if(d>=256&&d<65536) 37 printf("4 "); 38 else if(d>=16&&d<256) 39 printf("3 "); 40 else if(d>=4&&d<16) 41 printf("2 "); 42 else if(d>1&&d<4) 43 printf("1 "); 44 else if(d==1) 45 printf("0 "); 46 else 47 printf("TAT "); 48 } 49 return 0; 50 }
Wa代码:
1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<queue> 5 #include<algorithm> 6 #include<time.h> 7 using namespace std; 8 9 const int maxn = 2005; 10 const int N=1000007; 11 12 #define lson rt<<1///rt*2 13 #define rson rt<<1|1///rt*2+1 14 15 char s[N]; 16 17 int main() 18 { 19 int len,i; 20 21 while(scanf("%s", s) != EOF) 22 { 23 long long d=0; 24 len=strlen(s); 25 if(len>10) 26 { 27 printf("TAT "); 28 continue ; 29 } 30 for(i=0; i<len; i++) 31 d=d*10+s[i]-'0'; 32 33 if(d<4294967296) 34 { 35 if(d>=65536) 36 printf("5 "); 37 else if(d>=256) 38 printf("4 "); 39 else if(d>=16) 40 printf("3 "); 41 else if(d>=4) 42 printf("2 "); 43 else if(d>1) 44 printf("1 "); 45 else if(d==1) 46 printf("0 "); 47 } 48 else 49 printf("TAT "); 50 } 51 return 0; 52 }
很搞不懂,谁来解释一下 if else 1号 和 if else2号 的区别,~~~~(>_<)~~~~