http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1028

Digital Roots

时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte
总提交: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的更多相关文章

  1. HDU 1013 Digital Roots【字符串,水】

    Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  2. HDU 1013 Digital Roots(to_string的具体运用)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1013 Digital Roots Time Limit: 2000/1000 MS (Java/Othe ...

  3. Digital Roots 1013

    Digital Roots 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:456            测试通过:162 描述 T ...

  4. Eddy's digital Roots

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

  5. 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 ...

  6. HDU 1163 Eddy's digital Roots

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. HDOJ 1163 Eddy's digital Roots(九余数定理的应用)

    Problem Description The digital root of a positive integer is found by summing the digits of the int ...

  8. Eddy's digital Roots(九余数定理)

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  9. HDU1163 Eddy's digital Roots【九剩余定理】

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

随机推荐

  1. Android 开发Project中各个目录和文件的介绍

    如上图标号: 存放java文件的文件夹“src”: 由aapt工具根据应用中的资源文件自动生成的R.java文件,以及buildConfiger.java文件,这两个文件最好不要去修改: 存放各种资源 ...

  2. Ubunut 13.04下配置memcached、 python MySQLDB,python-memcache模块等

    一开始系统使用的是163的源,没有安装成功memcached,换了cn99的也不行,后来换了台湾的源,以下步骤才得以顺利进行. 更换源的方法可以参看我以前的帖子. 安装memached:sudo ap ...

  3. 射频识别技术漫谈(14)——S50与S70存取控制【worldsing笔记】

    存取控制指符合什么条件才能对卡片进行操作. S50和S70的块分为数据块和控制块,对数据块的操作有"读"."写"."加值"."减值 ...

  4. LDO稳压器工作原理

    LDO稳压器工作原理 随着便携式设备(电池供电)在过去十年间的快速增长,像原来的业界标准 LM340 和LM317 这样的稳压器件已经无法满足新的需要.这些稳压器使用NPN 达林顿管,在本文中称其为N ...

  5. Quartus II调用modelsim无缝仿真

    本篇文章为转载,写的不错,最近在学modelsim仿真,网上的教程很乱,把自己认为不错的整理贴出来,后面有机会会写个详细点的. Quartus 中调用modelsim的流程 1. 设定仿真工具 ass ...

  6. 从最近MySQL的优化工作想到的

    最近决定将以前同事写的存储过程查看一遍,寻找一些代码上写的不太好的地方,争取进行修改以后让这些过程达到一个很好的运行速度.下面是遇到的最多的几个问题. 我遇到了这样的一个SQL: select nam ...

  7. 测试JS基本类型以及对象的引用

    自己敲的. 1 <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js&qu ...

  8. cocos2dx中android下动态更新.so文件

    作者:HU 转载请注明,原文链接:http://www.cnblogs.com/xioapingguo/p/4037595.html  因为没用lua脚本写游戏,所以每次发布出去后,发现在bug,需要 ...

  9. 【转】于request.getSession(true/false/null)的区别

    http://blog.csdn.net/gaolinwu/article/details/7285783 关于request.getSession(true/false/null)的区别 一.需求原 ...

  10. Ubuntu装机必备

    sudo apt-get install rar unrar p7zip* sudo apt-get install tree sudo apt-get install wine sudo apt-g ...