HDU1013Digital Roots
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
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
Output
Sample Input
Sample Output
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- string n;
- while(cin>>n) {
- if(n[]=='')
- return ;
- int sum=;
- int root=;
- for(int i=; i<n.size(); i++)
- sum+=n[i]-'';
- while(sum||root>=) {//注意一下这里了就好
- if(sum) {
- root+=sum%;
- sum/=;
- }
- else{
- sum=root;
- root=;
- }
- }
- cout<<root<<endl;
- }
- return ;
- }
HDU1013Digital Roots的更多相关文章
- hdu--1013--Digital Roots(字符串)
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- gc roots 垃圾回收
gc roots包括以下几个: 虚拟机栈(栈桢中的本地变量表)中的引用对象 方法区中的类静态属性引用的对象 方法区中的常量引用的对象 本地方法栈中JNI(即native方法)的引用的对象 java,c ...
- Digital Roots 1013
Digital Roots 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:456 测试通过:162 描述 T ...
- 枚举GC Roots的实现
枚举根节点 从可达性分析中从GC Roots节点找引用链这个操作为例,可作为GC Roots的节点主要在全局性的引用(例如常量或类静态属性)与执行上下文(例如栈帧中的本地变量表)中,现在很多应用仅仅方 ...
- 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 ...
- Gym 100818F Irrational Roots (数学)
Irrational Roots http://acm.hust.edu.cn/vjudge/contest/view.action?cid=101594#problem/F [题意]: 判断一个整系 ...
- HDU1013_Digital Roots【大数】【水题】
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDU 1163 Eddy's digital Roots
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
随机推荐
- 重拾C,一天一点点_10
来博客园今天刚好两年了,两年前开始学编程. 忙碌近两个月,项目昨天上线了,真心不容易,也不敢懈怠,接下来的问题会更多.这两天调试服务器,遇到不少麻烦. 刚出去溜达了一下,晚上天凉了,现在手感觉凉的有点 ...
- Java迷题:等于,还是不等于?
等于还是不等于? 看来看下面的一段代码: public static void main(final String[] args) { Integer a = new Integer(100); In ...
- Lua 的函数库 01
这里只介绍和插件编写比较有关的几个函数. 详细的Lua手册请参照Lua Reference Manual 5.1. table函数库 一部分的table函数只对其数组部分产生影响, 而另一部分则对整个 ...
- p ython笔记第一天
一.Linux基础 - 计算机以及日后我们开发的程序防止的服务器的简单操作 二.Python开发 http://www.cnblogs.com/wupeiqi/articles/5433893.htm ...
- rails的字符编码
想练练手,随意的写了个登陆页面,简单的只有几行. <%= form_tag('login_check') do -%><%= text_field_tag 'user_name', ...
- webpack 学习笔记 01 使用webpack的原因
本系列文章实际上就是官网文档的翻译加上自己实践过程中的理解. 伴随着websites演化至web apps的过程,有三个现象是很明显的: 页面中有越来越多的Js. 客户端能做的事情越来越多. 越来越少 ...
- Huffman树的编码译码
上个学期做的课程设计,关于Huffman树的编码译码. 要求: 输入Huffman树各个叶结点的字符和权值,建立Huffman树并执行编码操作 输入一行仅由01组成的电文字符串,根据建立的Huffma ...
- 菜鸟学习Hibernate——简单的增、删、改、查操作
上篇博客利用Hibernate搭建起一个简单的例子,把数据库的映射显示了出来在上一篇的博客基础上这篇博客讲述如何利用Hinbernate框架实现简单的数据库操作. 1.加入junit.jar 2.新建 ...
- Lambda前世今生
1.学习资料 匿名函数 C#编程指南http://msdn.microsoft.com/zh-cn/library/bb882516.aspx Lambda表达式 C#编程指南http://msdn. ...
- hdu 5146 Sequence
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5146 Sequence Description Today we have a number sequ ...