码迷,mamicode.com
首页 > 其他好文 > 详细

【模拟】HDU 5752 Sqrt Bo

时间:2016-08-13 22:28:26      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:

  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\n");
13         else
14         if (strlen(st)==10 && strcmp(st,"2147483647")>0)
15             printf("5\n");
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\n",ans);
27         }
28     }
29     return 0;
30 }
View Code

 

【模拟】HDU 5752 Sqrt Bo

标签:

原文地址:http://www.cnblogs.com/Coolxxx/p/5769030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!