• hdu 5752 Sqrt Bo


    Sqrt Bo<Sqrt Bo/center>

    题意:

    给你一个数,问你最少开多少次,可以变成1。

    如果超过五次还没有变成1,就输出TAT

    题解:

    首先要大致估算一下,多少位的数开5次根号等于1,引用qsc:
    1->3->15->255->65535->4294967295
    所以最大是10位,所以开个long long换字符串,之后每次都根号,最后输出就好了

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    const int INF=0x3f3f3f3f;
    typedef long long ll;
    #define PU puts("");
    #define PI(A) printf("%d
    ",A)
    #define SI(N) scanf("%d",&(N))
    #define SII(N,M) scanf("%d%d",&(N),&(M))
    #define cle(a,val) memset(a,(val),sizeof(a))
    #define rep(i,b) for(int i=0;i<(b);i++)
    #define Rep(i,a,b) for(int i=(a);i<=(b);i++)
    #define reRep(i,a,b) for(int i=(a);i>=(b);i--)
    #define dbg(x) cout << #x << " = " << x << endl
    #define PIarr(a, n, m) rep(aa, n) { rep(bb, m) cout << a[aa][bb]<<" "; cout << endl; }
    const double EPS= 1e-9 ;
    
    /*  /////////////////////////     C o d i n g  S p a c e     /////////////////////////  */
    
    string s;
    
    int main()
    {
        while(cin>>s)
        {
            ll n=0;
            if (s.size()>18) {puts("TAT");continue;}
            for (int i=0;i<s.size();i++) n=n*10+s[i]-'0';
            bool fl=0;
            for (int i=1;i<=5;i++)
            {
                n=sqrt(n);
                if (n==1)
                {
                    fl=1;
                    cout<<i<<endl;
                    break;
                }
            }
    
            if (!fl) puts("TAT");
        }
        return 0;
    }
  • 相关阅读:
    如何写Makefile?
    C语言变量的存储类别详解
    Longest Palindrome Substring
    Count Primes
    Closest Binary Search
    Search Insert Position
    Set Matrix Zeros ****
    Search for a Range
    Two Sum II
    Jump Game
  • 原文地址:https://www.cnblogs.com/s1124yy/p/5709781.html
Copyright © 2020-2023  润新知