hdu5752Sqrt Bo+水题
来源:互联网 发布:js获取当前鼠标的位置 编辑:程序博客网 时间:2024/05/17 23:33
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 this problem.
Sample Input
233
233333333333333333333333333333333333333333333333333333333
Sample Output
3
TAT
题意:给一个数。问能不能5次内计算
直接观察就可以发现跟2的几次幂有关。
#include<cstdio>#include<cstring>#include<cmath>using namespace std;#define LL long longchar a[122];int main(){ while(scanf("%s",a)!=EOF){ int len=strlen(a); if(len>=11) printf("TAT\n"); else{ LL sum=0; for(int i=0;i<len;i++) sum=sum*10+a[i]-'0'; if(sum==0){ printf("TAT\n"); continue; } int cnt=0; //printf("%I64d\n",sum); while(sum>1){ sum=(int)(sqrt(sum)+0.0000001); cnt++; //printf("%I64d\n",sum); } if(cnt>5) printf("TAT\n"); else printf("%d\n",cnt); } } return 0;}
- hdu5752Sqrt Bo+水题
- BO
- HDU-5762-Teacher Bo-水题
- hdu 5752 Sqrt Bo (水题)
- hdu 5753 Permutation Bo (水题)
- HDU 2372 Sqrt Bo(水题)
- HDU 5752 Sqrt Bo(水题)
- HDU 5762 Teacher Bo (水题)
- 什么是BO?
- BO URL
- BO - Universe
- BO基础
- hdu5762Teacher Bo
- Sqrt Bo
- Permutation Bo
- Teacher Bo
- hdu5755Gambler Bo
- Teacher Bo
- LEETCode 264. Ugly Number II
- 回首过去,展望未来。
- JAVA笔记之复制文件篇
- hdu5752 Sqrt Bo(水)
- 单击按钮后实现按钮置换
- hdu5752Sqrt Bo+水题
- 编写实用的操作手册的一些建议,仅供参考
- c++设计模式之享元模式
- Android TV gridview 的按键事件响应巧变 && 事件分发机制
- ARM中通过寄存器确定GPIO的功能,通过程序控制寄存器。
- 凸包入门题 HDU 1392 凸包果题,求周长
- 顺序表应用3:元素位置互换之移位算法
- 《牛客面试算法题精讲第二季》专题1
- git服务器的使用