ACM——Digital Roots
http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1028
Digital Roots
总提交:493 测试通过:175
描述
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.
For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.
输入
The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero.
输出
For each integer in the input, output its digital root on a separate line of the output.
样例输入
24
39
0
样例输出
6
3
题目来源
Greater New York 2000


ACM——Digital Roots的更多相关文章
- HDU 1013 Digital Roots【字符串,水】
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1013 Digital Roots(to_string的具体运用)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1013 Digital Roots Time Limit: 2000/1000 MS (Java/Othe ...
- Digital Roots 1013
Digital Roots 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:456 测试通过:162 描述 T ...
- Eddy's digital Roots
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- Digital Roots 分类: HDU 2015-06-19 22:56 13人阅读 评论(0) 收藏
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- HDU 1163 Eddy's digital Roots
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDOJ 1163 Eddy's digital Roots(九余数定理的应用)
Problem Description The digital root of a positive integer is found by summing the digits of the int ...
- Eddy's digital Roots(九余数定理)
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDU1163 Eddy's digital Roots【九剩余定理】
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
随机推荐
- Linux下如何保持gnome-terminal窗口执行命令后停留而不立刻关闭(gnome-terminal -x)
Linux下如何保持gnome-terminal窗口执行命令后停留而不立刻关闭(gnome-terminal -x) 转自:http://jakfruit.blog.163.com/blog/stat ...
- Java 继承详解
什么是继承? 多个类中存在相同属性和行为时,将这些内容抽取到单独一个类中,那么多个类无需再定义这些属性和行为,只要继承那个类即可. 多个类可以称为子类,单独这个类称为父类.超类或者基类. 子类可以直接 ...
- 转载ASP.NET MVC 和ASP.NET Web Form简单区别
转载原地址 http://www.cnblogs.com/lei2007/p/3315431.html 概论: Asp.net 微软 提供web开发框架或者技术.分Web Form和ASP.NET ...
- hdoj 2829 Lawrence 四边形不等式优化dp
dp[i][j]表示前i个,炸j条路,并且最后一个炸在i的后面时,一到i这一段的最小价值. dp[i][j]=min(dp[i][k]+w[k+1][i]) w[i][j]表示i到j这一段的价值. # ...
- ThinkPHP CURD方法盘点:order方法
order方法属于模型的连贯操作方法之一,用于对操作的结果排序. 用法 $Model->where('status=1')->order('id desc')->limit(5)-& ...
- Compiling aSmack
For a recent mobile project we used XMPP. It worked really well and I’m keen to use it again. But, i ...
- 离线安装Cloudera Manager5.3.4与CDH5.3.4(二)
Cloudera Manager Server和Agent所有后发先至.也能够进行CDH5的安装和配置. 然后,主节点可以通过浏览器访问7180port测试(因为CM Server需要花时间来启动,可 ...
- iOS音频篇:AVPlayer的缓存实现
授权转载,作者:明仔Su(简书) 在上一篇文章<使用AVPlayer播放网络音乐>介绍了AVPlayer的基本使用,下面介绍如何通过AVAssetResourceLoader实现AVPla ...
- Python源码剖析
http://blog.csdn.net/balabalamerobert/article/details/570758
- insert erase和replace的例子
9.43 编写一个函数,接受三个string参数s.oldVal和newVal.使用迭代器及insert和erase函数将s中所有oldval替换为newVal.测试程序,用它替换通用的简写形式,如, ...