Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 77880    Accepted Submission(s): 24325

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
24
39
0
 



Sample Output
6
3
 
 
 #include<stdio.h>
int main()
{
long long int t;
scanf("%lld",&t);
while(t)
{
printf("%d\n",(t-)%+);
scanf("%lld",&t);
}
return ;
}

第一次的代码,没有考虑数字很大很大的情况下,所以一直是WA

下面使用字符串改进的代码,AC了

 #include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
string s;
while()
{
int m=;
cin>>s;
if(s[]-''==&&s.length()==)
break;
for(int i=;i<s.length();i++)
{
m+=s[i]-'';
}
cout<<(m-)%+<<endl;
}
}

1013 Realtime Status的更多相关文章

  1. [PHP]swoole_server几个进程的分工

    readme.md-/Users/zjh/Documents/我的文章/[PHP]swoole_server几个进程的分工 html{font-family: sans-serif;-ms-text- ...

  2. [PHP]Yii2框架的坑

    [PHP]Yii2框架的坑.md-/Users/zjh/Documents/我的文章/[PHP]Yii2框架的坑 html{font-family: sans-serif;-ms-text-size- ...

  3. [PHP]程序员技能栈

    [PHP]程序员技能栈.md-/Users/zjh/Documents/我的文章/[PHP]程序员技能栈 html{font-family: sans-serif;-ms-text-size-adju ...

  4. Color国际青年公寓

    Color国际青年公寓介绍.md-/Users/zjh/Documents html{font-family: sans-serif;-ms-text-size-adjust: 100%;-webki ...

  5. EXPDP IMPDP 知识总结

    Data Pump Export ATTACH Default: job currently in the user's schema, if there is only one Purpose(目的 ...

  6. 转贴---Performance Counter(包含最全的Windows计数器解释)

    http://support.smartbear.com/viewarticle/55773/ 这个Article中介绍了一个新工具,TestComplete,把其中涉及到性能计数器的部分摘抄出来了. ...

  7. Delphi 7生成XML

    文件格式为: Day 制1課 U12 ASSY01 Wrist 1009 0 2018/05/18 09:35:59 Day 制1課 U12 ASSY02 Wrist 1010 0 2018/05/1 ...

  8. Digital Twin 数字孪生

    GE的一个NB视频:http://v.youku.com/v_show/id_XMjk0NTMzODIyNA==.html http://www.gongkong.com/news/201701/35 ...

  9. Real-Time SQL Monitoring

    Real-Time SQL Monitoring可以在sql运行的时候监控其性能. 缺省情况下,单个sql执行花费的CPU或I/O时间超过5秒或sql并行执行的时候,Real-Time SQL Mon ...

随机推荐

  1. 对VC++6.0爱得深沉(一)安装vc++6.0,支持winXP,win7,win8.1,win10

    [欢迎入坑] 从这里起,我称VC++6.0为小c. 为什么我对小c爱得深沉? 虽然饱受非议,但是,我只想说,我太单纯,小c轻轻松松成功运行在各个win平台,对于我来说她:高速.小巧.便捷.听话.可定制 ...

  2. [译]Selenium Python文档:一、安装

    1.1.简介 Selenium Python为使用Selenium WebDriver来编写功能/验证测试提供了一个简单的API接口.通过Selenium Python API,你可以以一种非常直观的 ...

  3. WebX框架学习笔记之二----框架搭建及请求的发起和处理

    框架搭建 执行环境:windows.maven 执行步骤: 1.新建一个目录,例如:D:\workspace.注意在盘符目录下是无法执行成功的. 2.执行如下命令: mvn archetype:gen ...

  4. CSS.01 -- 选择器及相关的属性文本、文字、字体、颜色、

    与html相比,Css支持更丰富的文档外观,Css可以为任何元素的文本和背景设置颜色:允许在任何元素外围设置边框:允许改变文本的大小,装饰(如下划线),间隔,甚至可以确定是否显示文本. 什么是CSS? ...

  5. Linux中web服务运行情况的方法

    监控一般通过脚本实现,使用定时任务定期执行检测. 1.端口 本地:ss,netstat,lsof 远程:telnet,namp,nc 2.本地进程数 例如: lsof -i:80|wc -l ps - ...

  6. 环境搭建-VMware安装系统

    常用的虚拟化软件: 1.vmware:收费 commercial(商业版的) 2.vitualbox:free   虚拟化软件:vmware workstation(虚拟系统工作站)   安装系统任务 ...

  7. C# 索引同时含有数字和字符串的集合 同时具备IList和IDictionary的特点

    同时具备IList和IDictionary的特点的集合 [Serializable] public class MyCollection:IList { private readonly Dictio ...

  8. mysql的导入和导出

    MYSQL数据库导出 以root登录vps,执行以下命令导出. 1./usr/local/mysql/bin/mysqldump -u root -p123456 zhumaohai > /ho ...

  9. ReactJS入门3:组件的生命周期

    本文主要介绍组件的生命周期. 组建的生命周期主要分为3个:Mounting.Updating.Unmounting. 1. Mounting:组件被加载到DOM     在本阶段,主要有三个方法: 1 ...

  10. Android中的socket本地通讯框架

    一.先分析Native层: 1.C++基类SocketListener: class SocketListener {     int mSock;     const char *mSocketNa ...