HDU 1013 Digital Roots(to_string的具体运用)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1013
Digital Roots
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 90108 Accepted Submission(s): 28027
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.
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long LL;
int main()
{
string s;
LL sum;
while(cin>>s)
{
if(s=="")
break;
while(s.size()>)//当size==1的时候,就是答案
{
sum=;
for(int i=;i<s.size();i++)
{
sum+=(s[i]-'');//累加
}
s=to_string(sum);//转化成字符串
}
cout<<s<<endl;
}
return ;
}
HDU 1013 Digital Roots(to_string的具体运用)的更多相关文章
- HDU 1013 Digital Roots【字符串,水】
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1013 Digital Roots(字符串)
Digital Roots Problem Description The digital root of a positive integer is found by summing the dig ...
- HDU 1013.Digital Roots【模拟或数论】【8月16】
Digital Roots Problem Description The digital root of a positive integer is found by summing the dig ...
- HDU 1013 Digital Roots(字符串,大数,九余数定理)
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1013 Digital Roots 题解
Problem Description The digital root of a positive integer is found by summing the digits of the int ...
- hdu 1013 Digital Roots
#include <stdio.h> int main(void) { int m,i;char n[10000]; while(scanf("%s",&n)= ...
- HDU OJ Digital Roots 题目1013
/*Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDU - 1310 - Digital Roots
先上题目: Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- 杭电 1013 Digital Roots
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1013 反思:思路很简单,但是注意各位数加起来等于10的情况以及输入0的时候结束程序该怎么去表达 #in ...
随机推荐
- LDAP概念了解
LDAP是轻量目录访问协议,英文全称是Lightweight Directory Access Protocol,一般都简称为LDAP.LDAP支持TCP/IP,这对访问Internet是必须的. L ...
- PHP三维优先级运算
昨天去某大型公司面试,做了一套面试题,整套面试题的基础要求比较高,对于js的使用有一定的要求.在本次面试中碰到PHP三维运算优先级的问题,先看题: <?php $b=20; $c=40; $a= ...
- python apscheduler的使用
from apscheduler.schedulers.blocking import BlockingSchedulerfrom datetime import datetime def my_jo ...
- 使用JS完成首页轮播图效果
获取document.getElementById("id名称"); 事件onload 定时操作setInterval("changeImg()",3000); ...
- Activiti学习之HelloWorld程序
流程图 部署流程定义 /** * 部署流程定义 */ @Test public void deploymentProcessDefinition() { ProcessEngine processEn ...
- 中国gis100强
广州南方测绘仪器有限公司 北京四维图新科技股份有限公司 北京北斗星通导航技术股份有限公司 高德软件有限公司 北京合众思壮科技股份有限公司 中国地图出版社 广州中海达卫星导航技术股份有限公司 正元地理信 ...
- hiho 1015 KMP算法 && CF 625 B. War of the Corporations
#1015 : KMP算法 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在 ...
- python(day1-11)
day1:Python入门 day2:数字类型字符编码 day3:函数 day4:模块与包 day5:常用模块 day6:面向对象 day8:异常处理 day9:网络编程 day10:并发编程 day ...
- JBOSS参数调优
阅读目录 JBOSS参数调优 jvm调优讲解1 JVM调优讲解2 JVM常见配置汇总 JBOSS生产环境下JVM调优 JBOSS瘦身 JBoss性能优化:内存紧张的问题终于解决了(转载)--- ...
- 使用MapKit框架(持续更新)
使用MapKit框架 地图显示 最简单显示地图的代码: // // RootViewController.m // CoreLocation // // Copyright (c) 2014年 Y.X ...