HDU1013 Digital Roots
http://acm.hdu.edu.cn/showproblem.php?pid=1013
- #include<iostream>
- #include "cstdio"
- using namespace std;
- int main()
- {
- int n;
- while(~scanf("%d",&n)&&n)
- {
- int sum=;
- while(true){
- while(n>){
- sum+=n%;
- n/=;
- }
- if(sum>)
- {
- n=sum;sum=;
- }
- else{
- break;
- }
- }
- cout<<sum<<endl;
- }
- return ;
- }
就是wrong就是wrong.....是何原因?是何原因??
感谢http://blog.csdn.net/rongyongfeikai2/article/details/7588273让我快速意识到,大数陷阱
- #include "iostream"
- #include "cstdio"
- #include "string"
- using namespace std;
- int main()
- {
- string str;
- while(cin>>str&&str!="")
- {
- int len=str.length();
- int num=;
- for(int i=;i<len;i++){
- num+=str[i]-'';
- if(num>){num=num/+num%;}
- }
- cout<<num<<endl;
- }
- return ;
- }
HDU1013 Digital Roots的更多相关文章
- 解题报告:hdu1013 Digital Roots
2017-09-07 22:02:01 writer:pprp 简单的水题,但是需要对最初的部分进行处理,防止溢出 /* @theme: hdu 1013 Digital roots @writer: ...
- Digital Roots—HDU1013 2016-05-06 10:25 85人阅读 评论(0) 收藏
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- Digital Roots 1013
Digital Roots 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:456 测试通过:162 描述 T ...
- 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 ...
- HDU 1163 Eddy's digital Roots
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- ACM——Digital Roots
http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1028 Digital Roots 时间 ...
- HDOJ 1163 Eddy's digital Roots(九余数定理的应用)
Problem Description The digital root of a positive integer is found by summing the digits of the int ...
- Eddy's digital Roots(九余数定理)
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
随机推荐
- CSS3不一样的下拉选择框
本例中包含两个下拉选择框的动画示例,本例中并未使用select标签.本例中第一个案例也可用于标题.导航栏等位置. 案例一: html布局 <div class="content&quo ...
- error C2248: 'QObject::QObject' : cannot access private member declared in class 'QObject'
1.error C2471: cannot update program database vc90.pdb 解决方案:https://blog.csdn.net/shuixin536/article ...
- Centos6.5
1.首先我们需要检测系统是否自带安装mysql # yum list installed | grep mysql 2.如果发现有系统自带mysql,果断这么干 # yum -y remove mys ...
- CCF-NOIP-2018 提高组(复赛) 模拟试题(五)
T1 相遇 [问题描述] 在一场奇怪的梦里,小 Y 来到了一个神奇的国度.这个国度可以用一根数轴表示,小 Y 在 N 处,而小 Y 想吃的美食在 K 处.小 Y 有两种方式移动, 一种叫做步行, 一种 ...
- Halcon17对硬件配置要求
Halcon17对硬件配置要求 Halcon17已经发布出来了,很多朋友一定想安装这款机器视觉软件来学习,我们今天给大家讲解下,Halcon17对硬件配置的要求: Halcon17 For Wind ...
- Linux pthread 线程池实现
基于pthread封装了一个简易的ThreadPool,具有以下特性: 1.具有优先级的任务队列 2.线程池大小可以二次调整,增加线程或者删除空闲线程 3.任务两种重写方式,重写run或者使用函数回调 ...
- Spring Security 5.0.x 参考手册 【翻译自官方GIT-2018.06.12】
源码请移步至:https://github.com/aquariuspj/spring-security/tree/translator/docs/manual/src/docs/asciidoc 版 ...
- HDU 4729 An Easy Problem for Elfness(主席树)(2013 ACM/ICPC Asia Regional Chengdu Online)
Problem Description Pfctgeorge is totally a tall rich and handsome guy. He plans to build a huge wat ...
- ACM训练大纲
1. 算法总结及推荐题目 1.1 C++ STL • STL容器: set, map, vector, priority_queue, queue, stack, deque, bitset• STL ...
- Week7 Teamework from Z.XML-NABC
NABC 引言:我们团队计划做一个手机端的类RPG2d游戏.之所以我们定义为类RPG,是因为我们希望弱化RPG在游戏中的概念--减少或者排除人物对话等较为无趣的内容,而将重点放在玩家的娱乐享受中.为了 ...