HDU 2498 Digits
水题。题目这样定义的,另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相关推荐
- hdu 3022 Sum of Digits
http://acm.hdu.edu.cn/showproblem.php?pid=3022 题意: 最多不超过10000组数据,每组数据给定两个数n,m,求一个最小的数,使得该数每一位之和等于n,每 ...
- hdu 4333 Revolving Digits
http://acm.hdu.edu.cn/showproblem.php?pid=4333 对我来说这个题 太难了 看着标准程序敲的 伤不起呀 解析说是和KMP有关 不过已经变形的不成样子了 如 ...
- 【hdu 4333】Revolving Digits
[链接]http://acm.hdu.edu.cn/showproblem.php?pid=4333 [题意] 就是给你一个数字,然后把最后一个数字放到最前面去,经过几次变换后又回到原数字,问在这些数 ...
- HDU - 4333 Revolving Digits(扩展KMP)
题目链接:点击查看 题目大意:给出一个由 n 个数位组成的数字,现在可以通过将其不同的后缀移到前面来组成 n 个新的数字,现在要求出 n 个新数字进行去重后,有多少个新数字分别大于.等于.小于原数字 ...
- HDU - 4333 Revolving Digits 拓展KMP
传送门:点击打开链接 一个长度为lent的串T最多可以构造出lent个数字,所以这道题目的难点在于如何快速的将构造出的数字和原数字进行比较. 将两个T串合并成一个大的S串,构造出的数字实际上就是S的每 ...
- [ACM] hdu 1671 Phone List (字典树)
[ACM] hdu 1671 Phone List (字典树) Phone List Problem Description Given a list of phone numbers, determ ...
- hdu 1047 Integer Inquiry
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...
- hdu 3320 计算几何(三维图形几何变换)
openGL Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- hdu 1800 (map)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/ ...
最新文章
- Generator-ing Values
- 二、应用层协议概述与HTTP
- Python实现与LeetCode--堆
- c语言定义函数insert,c语言编写函数insert(char s1[ ],char s2[ ],int pos),实现在字符串s1中的指定位置pos处插入字符串s2。...
- Swagger:Rest API的描述语言
- 使用 XML 维护 Selenium 自动化测试脚本 ZT
- 恩智浦智能车摄像头循迹部分
- Windows Server 2013 安装zune 4.8中文版
- Mybatis-Plus:Sql 注入器(扩展BaseMapper)
- Linux perf 事件调度算法
- Ubuntu Server 20.04 下 HustOJ 安装
- ROS 问题(topic types do not match、topic datatype/md5sum not match、msg xxx have changed. rerun cmake)
- 北京剩女80万!全国十大单身男女盛产地都在哪?
- fiftyone安装使用亲测
- ERROR 1062 (23000): ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1'
- JavaMail发送邮件手机客户端图片无法显示
- 服务器宕机记录16.12.14
- max3485和max485区别
- ansys用什么cpu_如何为ANSYS mechanical高性能计算选用更合理的硬件配置
- [项目管理-22]:项目中开环、闭环、安全、监控四种沟通模型:UDP/TCP/SCTP/PID模型