当前位置:
首页 >
HDU 2498 Digits
发布时间:2025/3/19
39
豆豆
生活随笔
收集整理的这篇文章主要介绍了
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 5612 Baby Ming a
- 下一篇: rsync 相关参数