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. SHA1l加密

    public static string SHA1Encrypt(string sourceText) { SHA1 sha = new SHA1CryptoServiceProvider(); AS ...

  2. Android 5.0(棒棒糖))十大新特性

    Android 5.0(棒棒糖))十大新特性 1. 全新Material Design设计风格 Android Lollipop全新的设计语言是受到了多种因素影响,是一种大胆的平面化创新.换句话说,谷 ...

  3. ie旋转滤镜Matrix

    旋转一个元素算是一个比较常见的需求了吧,在支持CSS3的浏览器中可以使用transform很容易地实现,这里有介绍:http://www.css88.com/archives/2168,这里有演示ht ...

  4. Chrome 开发工具 Workspace 使用

    前端开发中我们经常要在浏览器中做一些细节调整,比如对 CSS 的微调,最快的方式当然是直接在 Chrome 的开发者工具中调整,但问题在于在控制台中调试好的数值我们还需要再在 CSS 源码中再写一次, ...

  5. JS页面打开方式丶对话框及页面跳转方式

    一.js页面的三种打开方式 1. window.open 2. window.navigate("url") 跳转到目标页面 3. window.location.href=&qu ...

  6. JS的DOM操作及动画

    JS的DOM操作DOM:Document Object ModelBOM:Bowers(浏览器) Object Model找到元素:var a=document.getElementById(&quo ...

  7. Zkdash安装

    zkdash是一个zookeeper的管理界面,也可以作为任何基于zookeeper的配置管理工具,比如:Qconf 1.拉取代码 #git clone https://github.com/irea ...

  8. 大数据测试之Hadoop的基本概念

    poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标,也是国内最早探索大数据测试培训的机构,开发了独有的课程体系.如果对课程感兴趣,请大 ...

  9. Android内存优化之OOM

    内容大多都是和OOM有关的实践总结概要.理解错误或是偏差的地方,还请多包涵指正,谢谢!本人Q:1524447071 (一)Android的内存管理机制 Google在Android的官网上有这样一篇文 ...

  10. 基于Excel参数化你的Selenium2测试代码