• hdu_5752_Sqrt Bo(xjb搞)


    题目链接:hdu_5752_Sqrt Bo

    题意:

    给你一个数,问你最少要开多少次方才能为1

    题解:

    我们发现如果给的数大于232 那么肯定在5次以内是开不出来的,所以直接输出TAT,然后小于的就模拟一下,注意1和0的特判就行

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <cmath>
     4 typedef long long ll;
     5 const ll INF = ((ll)1 << 32) - 1;
     6 char inf[15] ="4294967295";
     7 char n[105];
     8 int len;
     9 void fail()
    10 {
    11     printf("TAT
    ");
    12 }
    13 void success()
    14 {
    15     ll ans = 0;
    16     for (int i = 0; i < len; i++) ans = ans * 10 + n[i] - '0';
    17     if (ans == 1) {printf("1
    "); return;}
    18     else if (ans == 0) {printf("TAT
    "); return;}
    19     int cnt = 0;
    20     while (ans > 1) {ans = sqrt(ans); cnt++;}
    21     printf("%d
    ", cnt);
    22 }
    23 int main()
    24 {
    25     while (~scanf("%s", n))
    26     {
    27         len = strlen(n);
    28         if (len > 10) fail();
    29         else if (len < 10) success();
    30         else
    31         {
    32             for (int i = 0; i < 10; i++)
    33                 if (n[i] > inf[i]) {fail(); break;}
    34                 else if (n[i] < inf[i]) {success(); break;}
    35                 else if (i == 9 && n[i] == inf[i]) {success(); break;}
    36         }
    37     }
    38     return 0;
    39 }
    View Code
  • 相关阅读:
    什么是遍历?
    jQuery 尺寸 方法
    jQuery 操作 CSS
    删除元素/内容
    通过 after() 和 before() 方法添加若干新元素
    通过 append() 和 prepend() 方法添加若干新元素
    四个 jQuery 方法:
    设置内容
    jQuery 属性选择器
    jQuery 元素选择器
  • 原文地址:https://www.cnblogs.com/bin-gege/p/5708789.html
Copyright © 2020-2023  润新知