这题嘛,不用多说,难度不大,唯一要注意的,也是ACM经常耍的花招:1000以内的单次输入量。也就是说,它可能输入1000 个数字字符,直观点举例,就是:
8947129387523745194375983274597435792834527345297349594375972345414132413577230
诸如此类。
所以必须用字符串来解决。
------------------------------------------原题如下 ---------------------------------------------
Digital Roots
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19048Accepted Submission(s): 5487
Problem Description
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.
Input
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.
Output
For each integer in the input, output its digital root on a separate line of the output.
Sample Input
Sample Output
Source
分享到:
相关推荐
reasons: to limit the length of the paper and because methods dealing with roots, seeds and fruits have some peculiarities that would warrant a specific survey. The selected proposals are divided into...
The roots of an arbitrary function or equation are calculated
《ROOTS品牌管理方法论白皮书》.pdf
roots, 快速高级前端开发工具包 根是一个快速。简单且可以定制的static 站点编译器。它不在积极开发中,也不会增加新特性。 根团队现在正在处理 spike,它已经匹配和取代了根的capabilities 。 我们鼓励你在开始新...
roots-example-project.com, 根堆栈工程( 格,基岩,Sage ) 根示例项目这里知识库是如何集成和使用以下项目的一个示例:基岩网格Sage ( 带土壤的)有关...这个项目是一个完整的工作示例,部署在 Digital Ocean 512MB dro
Roots最吸引人的地方是它清理了很多wordpress相关的东西,这样你可以花更多的时间来写代码而不是处理WordPress的设置。 用户可以移除bootstrap用其他CSS框架代替。支持多种语言(Brazilian Portuguese, Bulgarian, ...
Polynomial Root Finder is a reliable and fast C program (+ Matlab gateway) for finding all roots of a complex polynomial.
Computing Roots of Polynomials ,采用数值方法求根,速度快,很好
roots of quatratic eq
Roots_uniqe.m
求一元二次方程ax2 + bx + c = 0 的根,不管它的根是实根还是复根,有一个根还是两个根。
fixed point iteration for finding roots
自动部署 WordPress 和 Roots 对于本地 Ubuntu 14.04 开发环境。 需要 。 注意:我对 BASH 脚本很陌生,所以请仔细阅读此代码。 它对我们很有效,但使用风险自负! ##它能做什么## 在/var/www为站点创建一个新...
poj 1284 Primitive Roots.md
roots_config = require ( ' roots-config ' ) module . exports = extensions : [ roots_config ()] 用法 Roots config 是一个非常基本的便利扩展。 很多时候,您希望将所有项目的配置值存储在一个地方,并让它们...
fileSystems-roots.js
Roots_exist1.m
Mathematics Numerical Algorithms using matlab code
Roots是一款针对自闭症儿童的应用程序,他们大多是语言障碍严重的儿童,因此,他们难以通过口头语言进行有效交流。 我们已经研究和探索了补充性和替代性交流解决方案,以帮助这个孩子表达他们的想法,需求,欲望或...
Functional roots of the sine function