zoukankan      html  css  js  c++  java
  • hdoj 5752

    Let's define the function f(n)=n−−√f(n)=⌊n⌋. 

    Bo wanted to know the minimum number yy which satisfies fy(n)=1fy(n)=1. 

    note:f1(n)=f(n),fy(n)=f(fy1(n))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.

    InputThis problem has multi test cases(no more than 120120). 

    Each test case contains a non-negative integer n(n<10100)n(n<10100).
    OutputFor each test case print a integer - the answer yyor a string "TAT" - Bo can't solve this problem.Sample Input

    233
    233333333333333333333333333333333333333333333333333333333

    Sample Output

    3
    TAT


     1 /*
     2 要在五次内开跟达到1,第一次要在4以内,第二次在16以内,
     3     第三次256,第四次65536,第五次4294967296,所以超过10位的都是TAT*/
     4 
     5 #include<cstdio>
     6 #include<iostream>
     7 #include<cstring>
     8 #include<queue>
     9 #include<cmath>
    10 using namespace std;
    11 
    12 char ch[110];
    13 
    14 long long i;
    15 const long long num=4294967296-1;
    16 
    17 int main()
    18 {
    19     while(~scanf("%s",ch))
    20     {
    21         int r=strlen(ch);
    22         int l=0;
    23         while(ch[l]=='0') l++;
    24         if(r-l>10)
    25         {
    26             printf("TAT
    ");
    27             continue ;
    28         }
    29         i=0;
    30         while(l<r)
    31         {
    32             i=i*10+(ch[l]-'0');
    33             l++;
    34         }
    35         //cout<<i<<endl;
    36         if(i>num||i==0)
    37         {
    38             printf("TAT
    ");
    39         }
    40         else
    41         {
    42             int ii=0;
    43             while(i!=1)
    44             {
    45                 i=(long long )sqrt(i);
    46                 //cout<<i<<endl;
    47                 ii++;
    48             }
    49             printf("%d
    ",ii);
    50         }
    51     }
    52 }
     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <math.h>
     4 #include <string.h>
     5 using namespace std;
     6 #define MAXN 10000000
     7 char str [MAXN];
     8 int main()
     9 {
    10     while(~scanf("%s",str)){
    11         int len=strlen(str);
    12         if(len>10){printf("TAT");continue;}
    13         else{
    14             long long  n=0;bool flag=0;
    15             for(int i=0;i<len;i++) n=n*10+str[i]-'0';
    16             for(int i=1;i<=5;i++){
    17                 n=sqrt(n);
    18                 if(n==1){flag=1;printf("%d
    ",i);break;}
    19             }
    20             if(flag==0) printf("TAT");
    21         }
    22     }
    23     return 0;
    24 }
  • 相关阅读:
    Python向上取整,向下取整以及四舍五入函数
    Python字符串操作之字符串分割与组合
    python第四十七课——类属性和函数属性
    python第四十六课——函数重写
    LR进行接口测试
    Linux安装rpc监控系统资源
    本文将详细介绍oracle 10g OEM常规错误
    windows下卸载oracle11g
    Vi编辑器修改文件.bash_profile可解决backspace出现乱码问题,rlwrap 的安装。
    vim 编辑器常用命令
  • 原文地址:https://www.cnblogs.com/z-712/p/7324152.html
Copyright © 2011-2022 走看看