zoukankan      html  css  js  c++  java
  • Sqrt Bo hdu 5752

    Sqrt Bo

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
    Total Submission(s): 0    Accepted Submission(s): 0


    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(fy1(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
     
     
     
    题意:给出一个字符串,若开五次根号能开到1,则输出开方次数,否则输出“TAT”。
     
    打了一下午比赛做了一道这么个签到题。。。%>_<%
     
     
     
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <algorithm>
    #include <cstdlib>
    #include <cstring>
    using namespace std;
    #define maxn 1120
    char str[maxn];
    
    int main()
    {
        while(scanf("%s", str)!=EOF)
        {
            int ans = 0;
            long long n = 0;
    
            for(int i=0; str[i] && i<11; i++)
                n = n*10+str[i]-'0';
    
            while(n != 1)
            {
                n = sqrt(n);
                ans ++;
                
                if(ans>6)
                    break;
            }
    
            if(ans <= 5) printf("%d
    ", ans);
    
            else   printf("TAT
    ");
    
        }
    
        return 0;
    }
    View Code
  • 相关阅读:
    静态资源分析 ------ CocosCreator
    性能分析 ------ CPU运行卡点
    神犇的blog
    0x01-1 原码 反码 补码 概念 原理 详解
    埃拉托色尼素数筛法(转)
    Miller-Rabin概率素数测试算法(转)
    欧拉函数(转)
    中国剩余定理(孙子定理)详解 (转)
    负数取模(转)
    HDU1430 BFS + 打表 + 康托展开(转)
  • 原文地址:https://www.cnblogs.com/daydayupacm/p/5708195.html
Copyright © 2011-2022 走看看