HDU - 1013
wa了两遍:
(1)没有弄清楚输入数据的范围,实际上是字符串输入,数字很大。
(2)此题太水,没有标数据范围。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring> #define ll long long
using namespace std;
#define maxn 1000000000
char s[maxn]; int main()
{
while(~scanf("%s",s))
{
if(s[]=='')
break;
ll sum=;
ll len=strlen(s); //(1)
for(int i=; i<len; i++)
{
sum+=s[i]-'';
} ll tmp=sum;
while(sum>=)
{
sum=;
while(tmp)
{
sum+=tmp%;
tmp/=; }
tmp=sum;
}
cout<<sum<<endl;
}
return ;
}
HDU - 1013的更多相关文章
- 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(to_string的具体运用)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1013 Digital Roots Time Limit: 2000/1000 MS (Java/Othe ...
- hdu 1013 Digital Roots
#include <stdio.h> int main(void) { int m,i;char n[10000]; while(scanf("%s",&n)= ...
- 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 过山车 匈牙利算法(代码+详细注释)
过山车 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- 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题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
随机推荐
- JS--编码规范
1. 请修复给定的 js 代码中,函数定义存在的问题 function functions(flag) { if (flag) { function getValue() { return 'a'; ...
- iOS 封装SDK以及封装时bundle文件的处理
这篇教程的主要目的是解释怎么样在你的iOS工程中创建并使用一个SDK,俗称.a文件. 环境:xcode 9.0 创建一个静态库工程 打开Xcode,点击File\New\Project, 选择iOS\ ...
- PHP实现微信企业付款
一.封装微信企业付款类WeiXinPayToUser,如下图代码所示: class WeixinPayToUser { /** * API 参数 * @var array * 'mch_appid' ...
- Firefox 中出现的 “Network Protocol Error”怎么办
Mozilla Firefox 多年来一直是我的默认 Web 浏览器,我每天用它来进行日常网络活动,例如访问邮件,浏览喜欢的网站等.今天,我在使用 Firefox 时遇到了一个奇怪的错误.我试图在 R ...
- MacOS搭建本地服务器
MacOS搭建本地服务器 一,需求分析 1.1,开发app(ios android)时通常需往app中切入web页面,直接导入不行,故需搭建本地的测试网站服务,通过IP嵌入访问页面. 1.2,开发小程 ...
- java内存模型详解
对于本篇文章,将从四个概念来介绍:内存模型基础,重排序,顺序一致性和happens-before 1.内存模型基础 在并发编程中,有两个关键问题:线程之间如何通信和如何同步.由此而引出了两种并发模型: ...
- svn 服务器部署
系统环境:CentOS 7.x安装方式:yum install (源码安装容易产生版本兼容的问题)安装软件:系统自动下载SVN软件 #检查是否安装了低版本的SVN[root@localhost /]# ...
- Java并发编程:volatile关键字解析(转载)
转自https://www.cnblogs.com/dolphin0520/p/3920373.html Java并发编程:volatile关键字解析 Java并发编程:volatile关键字解析 ...
- CSS属性速查表
前面的话 本文将按照布局类属性.盒模型属性.文本类属性.修饰类属性这四个分类,对CSS常用属性进行重新排列,并最终设置为一份stylelintrc文件 布局类 1.定位 position z-inde ...
- 有关swiper动态改变数据遇到的坑(不能自动滚动,自动跟新数据,切换不正常)
以前都觉得swiper的使用很简单,那是因为使用swiper时都是写的数据,按照官网上介绍直接初始化swiper,随便丢一个地方初始化就ok了,但是在很多需求中,我们都需要动态的改变数据,这样可能就会 ...