HDU5752 Sqrt Bo
来源:互联网 发布:web前端和java哪个难 编辑:程序博客网 时间:2024/05/18 03:23
题目链接:HDU5752
Sqrt Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 639 Accepted Submission(s): 295
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
题意:对一个大数不断开方向下取整,问多少次可以开成1,多于5次输出TAT。
题目分析:显然2^2,2^4,2^8,2^16,2^32是分界点,对可能在2^32以内的数判断下属于那个区间即可,注意对0的特判,0时输出TAT。
//// main.cpp// Sqrt Bo//// Created by teddywang on 2016/7/27.// Copyright © 2016年 teddywang. All rights reserved.//#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){ long long int ans[10]; ans[1]=1;ans[2]=4; ans[3]=16;ans[4]=256; ans[5]=256*256;ans[6]=ans[5]*ans[5]; char s[2000]; while(~scanf("%s",s)) { if(strcmp(s,"0")==0) printf("TAT\n"); else{ int flag=1; if(strlen(s)<=10) { long long buf=0; for(int i=0;i<strlen(s);i++) { buf=10*buf+s[i]-'0'; } for(int j=1;j<6;j++) { if(buf>=ans[j]&&buf<ans[j+1]) { cout<<j<<endl; flag=0; break; } } } if(flag==1) printf("TAT\n"); } }}
0 0
- HDU5752 Sqrt Bo
- HDU5752 Sqrt Bo
- HDU5752 Sqrt Bo
- hdu5752 Sqrt Bo(水)
- hdu5752——Sqrt Bo(水)
- hdu5752 2016 Multi-University Training Contest 3 Sqrt Bo 解题报告
- Sqrt Bo
- 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
- 杭电5752之Sqrt Bo
- hdu 5752 Sqrt Bo (水题)
- hdu 5752 Sqrt Bo(水)
- HDU 5752 Sqrt Bo(多校3--1001)
- visio2016企业批量授权版本的激活方式
- 如何让iOS应用从容地崩溃
- 屏蔽不需要的蜘蛛节省服务器资源
- lua文件读写
- zookeeper连接超时问题排查
- HDU5752 Sqrt Bo
- hdu 1281(二分图匹配+增广路)
- Redisson分布式锁实现分析
- ubuntu 14.04 更换源的方法
- final作用
- android EditText 字体下面有红线的修复
- Win7自带驱动备份功能使用教程
- 直播飘心功能实现
- Unity3d的Vector3.forward和tansform.forward区别