zoukankan      html  css  js  c++  java
  • 【模拟】HDU 5752 Sqrt Bo

    题目链接:

      http://acm.hdu.edu.cn/showproblem.php?pid=5752

    题目大意

      定义f(n)=√n⌋,fy(n)=f(fy-1(n)),求y使得fy(n)=1。如果y>5输出TAT。(n<10100)

    题目思路:

      【模拟】

      5层迭代是232,所以特判一下层数是5的,其余开根号做。注意数据有0。

      队友写的。

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<math.h>
     4 int main()
     5 {
     6     char st[150];
     7     int temp;
     8     int ans;
     9     while(scanf("%s",st)!=EOF)
    10     {
    11         if (st[0]=='0' || strlen(st)>10 || strlen(st)==10 && strcmp(st,"4294967295")>0)
    12             printf("TAT
    ");
    13         else
    14         if (strlen(st)==10 && strcmp(st,"2147483647")>0)
    15             printf("5
    ");
    16         else
    17         {
    18             ans=0;
    19             sscanf(st,"%d",&temp);
    20             while(temp!=1)
    21             {
    22                 temp=(int)(sqrt(double(temp)));
    23                 ans++;
    24             }
    25             if (ans==0) ans=1;
    26             printf("%d
    ",ans);
    27         }
    28     }
    29     return 0;
    30 }
    View Code
  • 相关阅读:
    LeetCode "Sum Root to Leaf Numbers"
    LeetCode "Single Number"
    POJ #1033
    POJ #1011
    POJ #2411
    POJ #1276
    POJ #1260
    POJ #1221
    POJ #1080
    POJ #1050
  • 原文地址:https://www.cnblogs.com/Coolxxx/p/5769030.html
Copyright © 2011-2022 走看看