HDU5752 Sqrt Bo (2016 multi-school training)

Source: Internet
Author: User
Tags square root

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.