Sqrt Bo
Time limit:2000/1000 MS (java/others) Memory limit:131072/131072 K (java/others)
Total submission (s): 1173 Accepted Submission (s): 528
problem DescriptionLet ' s define the functionf(n)=⌊n−−√⌋ .
Bo wanted to know the minimum numberywhich satisfiesfy(n)=1 .
NoteF1(N)=F(N),fy(n)=F(fy−1(n))
It is a pity, so 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.
InputThis problem have multi test cases (no more than< Span id= "mathjax-span-61" class= "Mrow" >120 ).
Each test case contains a non-negative integer n (n< Span id= "mathjax-span-68" class= "Mo" ><10100) .
OutputFor each test case, print a integer-the answer y or a string "TAT"-Bo can ' t solve this problem.
Sample Input233233333333333333333333333333333333333333333333333333333333
Sample Output 3 TAT
Test instructions: Give a string, if open five square root can open to 1, then the output of the number of times, otherwise output "TAT".
1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5#include <string>6 using namespacestd;7typedefLong Longll;8typedef unsignedLong Longull;9typedefLong Doubleld;Ten One intMain () A { - Charstr[ +]; - ll I,len; thell n =0, ans =0; - while(~SCANF ("%s", str)) - { -Len =strlen (str); + if(len>Ten) - { +i =0; A } at Else - { -i =1; - for(intj =0; STR[J] && J < One; J + +) -N. = nTen+ str[j]-'0'; - //cout << n << endl; in while(n! =1) - { ton = (Long Long) sqrt (Double) n); +ans++; - if(Ans >5) the Break; * } $ }Panax Notoginsengn =0; - //cout << i << ' << ans << endl; the if(I && ans <=5) +cout << ans <<Endl; A Else thecout <<"tat\n"; +Ans =0; -i =0; $ } $ return 0; -}
View Code
HDU5752 Sqrt Bo (2016 multi-school training)