http://acm.hdu.edu.cn/showproblem.php?pid=1013

  1. #include<iostream>
  2. #include "cstdio"
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. while(~scanf("%d",&n)&&n)
  9. {
  10. int sum=;
  11. while(true){
  12. while(n>){
  13. sum+=n%;
  14. n/=;
  15. }
  16. if(sum>)
  17. {
  18. n=sum;sum=;
  19. }
  20. else{
  21. break;
  22. }
  23. }
  24. cout<<sum<<endl;
  25. }
  26. return ;
  27. }

就是wrong就是wrong.....是何原因?是何原因??

感谢http://blog.csdn.net/rongyongfeikai2/article/details/7588273让我快速意识到,大数陷阱

  1. #include "iostream"
  2. #include "cstdio"
  3. #include "string"
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string str;
  9. while(cin>>str&&str!="")
  10. {
  11. int len=str.length();
  12. int num=;
  13. for(int i=;i<len;i++){
  14. num+=str[i]-'';
  15. if(num>){num=num/+num%;}
  16. }
  17. cout<<num<<endl;
  18. }
  19. return ;
  20. }

HDU1013 Digital Roots的更多相关文章

  1. 解题报告:hdu1013 Digital Roots

    2017-09-07 22:02:01 writer:pprp 简单的水题,但是需要对最初的部分进行处理,防止溢出 /* @theme: hdu 1013 Digital roots @writer: ...

  2. 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 ...

  3. Digital Roots 1013

    Digital Roots 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:456            测试通过:162 描述 T ...

  4. Eddy's digital Roots

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  5. 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 ...

  6. HDU 1163 Eddy's digital Roots

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. ACM——Digital Roots

    http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1028 Digital Roots 时间 ...

  8. HDOJ 1163 Eddy's digital Roots(九余数定理的应用)

    Problem Description The digital root of a positive integer is found by summing the digits of the int ...

  9. Eddy's digital Roots(九余数定理)

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

随机推荐

  1. CSS3不一样的下拉选择框

    本例中包含两个下拉选择框的动画示例,本例中并未使用select标签.本例中第一个案例也可用于标题.导航栏等位置. 案例一: html布局 <div class="content&quo ...

  2. 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 ...

  3. Centos6.5

    1.首先我们需要检测系统是否自带安装mysql # yum list installed | grep mysql 2.如果发现有系统自带mysql,果断这么干 # yum -y remove mys ...

  4. CCF-NOIP-2018 提高组(复赛) 模拟试题(五)

    T1 相遇 [问题描述] 在一场奇怪的梦里,小 Y 来到了一个神奇的国度.这个国度可以用一根数轴表示,小 Y 在 N 处,而小 Y 想吃的美食在 K 处.小 Y 有两种方式移动, 一种叫做步行, 一种 ...

  5. Halcon17对硬件配置要求

     Halcon17对硬件配置要求 Halcon17已经发布出来了,很多朋友一定想安装这款机器视觉软件来学习,我们今天给大家讲解下,Halcon17对硬件配置的要求: Halcon17 For Wind ...

  6. Linux pthread 线程池实现

    基于pthread封装了一个简易的ThreadPool,具有以下特性: 1.具有优先级的任务队列 2.线程池大小可以二次调整,增加线程或者删除空闲线程 3.任务两种重写方式,重写run或者使用函数回调 ...

  7. Spring Security 5.0.x 参考手册 【翻译自官方GIT-2018.06.12】

    源码请移步至:https://github.com/aquariuspj/spring-security/tree/translator/docs/manual/src/docs/asciidoc 版 ...

  8. 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 ...

  9. ACM训练大纲

    1. 算法总结及推荐题目 1.1 C++ STL • STL容器: set, map, vector, priority_queue, queue, stack, deque, bitset• STL ...

  10. Week7 Teamework from Z.XML-NABC

    NABC 引言:我们团队计划做一个手机端的类RPG2d游戏.之所以我们定义为类RPG,是因为我们希望弱化RPG在游戏中的概念--减少或者排除人物对话等较为无趣的内容,而将重点放在玩家的娱乐享受中.为了 ...