HDU-5752 Sqrt Bo(处理字符串)
来源:互联网 发布:orancle in优化 编辑:程序博客网 时间:2024/06/08 07:33
Sqrt Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1346 Accepted Submission(s): 600
Problem Description
Let's define the function f(n)=⌊n−−√⌋ .
Bo wanted to know the minimum numbery 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.
Bo wanted to know the minimum number
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 120 ).
Each test case contains a non-negative integern(n<10100) .
Each test case contains a non-negative integer
Output
For each test case print a integer - the answer y or a string "TAT" - Bo can't solve this problem.
Sample Input
233233333333333333333333333333333333333333333333333333333333
Sample Output
3TAT
由2五次平方得到2^32次方,即10的9次方,int不会爆
太大了,先用字符串存储,符合再转化成数字
/**/#include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;//typedef long long ll;int main(){ char str[105]; while(~scanf("%s",str)) { int len = strlen(str); if(len >10 || strcmp(str,"0") == 0)//如果太长或者是0 printf("TAT\n"); else { long long ans = 0; for(int i = 0;i < len;i++) { ans = ans*10 + str[i] - '0'; } int sum = 0; while(ans > 1) { sum++; ans = floor(sqrt(ans)); } if(sum <= 5) printf("%d\n",sum); else printf("TAT\n"); } } return 0;}
0 0
- HDU-5752 Sqrt Bo(处理字符串)
- hdu 5752 Sqrt Bo
- HDU 5752 Sqrt Bo
- hdu 5752 Sqrt Bo
- HDU 5752 Sqrt Bo
- HDU-5752-Sqrt Bo-水
- 【模拟】HDU 5752 Sqrt Bo
- hdu 5752 Sqrt Bo (水题)
- hdu 5752 Sqrt Bo(水)
- HDU 5752 Sqrt Bo(多校3--1001)
- HDU 5752 Sqrt Bo(水题)
- HDU 5752 Sqrt Bo(水~)
- HDU 2372 Sqrt Bo(水题)
- Sqrt Bo
- Sqrt Bo
- hdu 5752 Sqrt Bo(2016 Multi-University Training Contest 3——水题)
- 2016 Multi-University Training Contest 3 hdu 5752 Sqrt Bo【思维】
- 杭电5752之Sqrt Bo
- css3 box-sizing属性
- 郑轻OJ/ ZZULIOJ 1053 正弦函数
- Android 应用启动速度优化之 Systrace 的使用
- Volley之Get
- ionic之搜索框浮动在轮播图片上
- HDU-5752 Sqrt Bo(处理字符串)
- BCNF范式(匡正的第三范式)、第四范式和第五范式
- Linux下段错误的原因以及调试方法
- svn 本地仓库使用
- 远程调试 Azure Web App
- simhash与重复信息识别(二)
- JAVA多线程的个人理解
- android:theme中各个颜色的对应位置
- Android之判断网络类型