水题。题目这样定义的,另f(x)为x有几位,x[i]=f(x[i-1]);

求最小的i使得x[i]==x[i-1]

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
using namespace std;char s[1000000+10];
int x[1000000+10];int f(int n)
{int res=0;while(n){n=n/10;res++;}return res;
}int main()
{while(~scanf("%s",s)){if(strcmp("END",s)==0) break;int len=strlen(s);x[1]=len;if(strlen(s)==1&&s[0]=='1') printf("1\n");{int now=2;while(1){x[now]=f(x[now-1]);if(x[now]==x[now-1]){printf("%d\n",now);break;}now++;}}}return 0;
}

转载于:https://www.cnblogs.com/zufezzt/p/5161098.html

HDU 2498 Digits相关推荐

  1. hdu 3022 Sum of Digits

    http://acm.hdu.edu.cn/showproblem.php?pid=3022 题意: 最多不超过10000组数据,每组数据给定两个数n,m,求一个最小的数,使得该数每一位之和等于n,每 ...

  2. hdu 4333 Revolving Digits

    http://acm.hdu.edu.cn/showproblem.php?pid=4333 对我来说这个题 太难了  看着标准程序敲的  伤不起呀 解析说是和KMP有关 不过已经变形的不成样子了 如 ...

  3. 【hdu 4333】Revolving Digits

    [链接]http://acm.hdu.edu.cn/showproblem.php?pid=4333 [题意] 就是给你一个数字,然后把最后一个数字放到最前面去,经过几次变换后又回到原数字,问在这些数 ...

  4. HDU - 4333 Revolving Digits(扩展KMP)

    题目链接:点击查看 题目大意:给出一个由 n 个数位组成的数字,现在可以通过将其不同的后缀移到前面来组成 n 个新的数字,现在要求出 n 个新数字进行去重后,有多少个新数字分别大于.等于.小于原数字 ...

  5. HDU - 4333 Revolving Digits 拓展KMP

    传送门:点击打开链接 一个长度为lent的串T最多可以构造出lent个数字,所以这道题目的难点在于如何快速的将构造出的数字和原数字进行比较. 将两个T串合并成一个大的S串,构造出的数字实际上就是S的每 ...

  6. [ACM] hdu 1671 Phone List (字典树)

    [ACM] hdu 1671 Phone List (字典树) Phone List Problem Description Given a list of phone numbers, determ ...

  7. hdu 1047 Integer Inquiry

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...

  8. hdu 3320 计算几何(三维图形几何变换)

    openGL Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  9. hdu 1800 (map)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/ ...

最新文章

  1. Generator-ing Values
  2. 二、应用层协议概述与HTTP
  3. Python实现与LeetCode--堆
  4. c语言定义函数insert,c语言编写函数insert(char s1[ ],char s2[ ],int pos),实现在字符串s1中的指定位置pos处插入字符串s2。...
  5. Swagger:Rest API的描述语言
  6. 使用 XML 维护 Selenium 自动化测试脚本 ZT
  7. 恩智浦智能车摄像头循迹部分
  8. Windows Server 2013 安装zune 4.8中文版
  9. Mybatis-Plus:Sql 注入器(扩展BaseMapper)
  10. Linux perf 事件调度算法
  11. Ubuntu Server 20.04 下 HustOJ 安装
  12. ROS 问题(topic types do not match、topic datatype/md5sum not match、msg xxx have changed. rerun cmake)
  13. 北京剩女80万!全国十大单身男女盛产地都在哪?
  14. fiftyone安装使用亲测
  15. ERROR 1062 (23000): ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1'
  16. JavaMail发送邮件手机客户端图片无法显示
  17. 服务器宕机记录16.12.14
  18. max3485和max485区别
  19. ansys用什么cpu_如何为ANSYS mechanical高性能计算选用更合理的硬件配置
  20. [项目管理-22]:项目中开环、闭环、安全、监控四种沟通模型:UDP/TCP/SCTP/PID模型

热门文章

  1. xgboost与coo_matrix
  2. r 保留之前曲线_R简单数据处理和分析
  3. python中使用格式化字符串
  4. 天翼云从业认证(1.5)了解Windows和Linux两种操作系统的常见命令和操作
  5. django构建网页_通过解决问题的方式学习django,律师如何构建副业
  6. 读债务危机0812:接管房利美和房地美
  7. 笔记-信息系统安全管理-网络安全防御
  8. 不建议在Docker中部署数据库
  9. Three.js中实现点击按钮添加删除旋转立方体
  10. MyBatis中传递数组参数和List参数时if-test判空和判断长度的写法