别人的代码开始自己不知道什么数论解法:

  1. ab*ab=(a*10+b)(a*10+b)=a^2*100+2ab*10+b^2
  2. 所以the root digital=(a+b)*(a+b);
  3. 而数论中的定理:两数之积对9取余数等于两数对9的余数的乘积。
  4.  
  5. 代码:
  6. #include"stdio.h"
  7. int main()
  8. {
  9. int i,n,sum;
  10. while(scanf("%d",&n)!=EOF&&n!=0)
  11. {
  12. sum=1;
  13. for(i=0;i<n;i++)
  14. {
  15. sum=sum*n%9;
  16. }
  17. if(sum==0)
  18. printf("9\n");
  19. else
  20. printf("%d\n",sum);
  21. }
  22. return 0;
  23. }

我的ac代码:

  1. #include<stdio.h>
  2. __int64 seach(__int64 u) {
  3. __int64 sum=0;
  4. while(u) {
  5. sum=sum+u%10;
  6. u/=10;
  7. }
  8. if(sum<10)
  9. return sum;
  10. return seach(sum);
  11. }
  12. __int64 dfs(__int64 n,__int64 index) {
  13. if(index==1)
  14. return n;
  15. if(index==0)
  16. return 1;
  17. if(index%2==1)
  18. return n*dfs(seach(n*n),index/2);
  19. return dfs(seach(n*n),index/2);
  20. }
  21. int main() {
  22. __int64 n,m,i,j,k;
  23. while(scanf("%I64d",&n),n) {
  24. printf("%I64d\n",seach(dfs(seach(n),n)));
  25. }
  26. return 0;
  27. }

hdu 1163的更多相关文章

  1. HDU 1163 Eddy's digital Roots(模)

    HDU 1163 题意简单,求n^n的(1)各数位的和,一旦和大于9,和再重复步骤(1),直到和小于10. //方法一:就是求模9的余数嘛! (228) leizh007 2012-03-26 21: ...

  2. hdu 1163 Eddy's digital Roots 【九余数定理】

    http://acm.hdu.edu.cn/showproblem.php?pid=1163 九余数定理: 如果一个数的各个数位上的数字之和能被9整除,那么这个数能被9整除:如果一个数各个数位上的数字 ...

  3. HDU 1163 Eddy's digital Roots

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

  4. hdu 1163 九余数定理

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

  5. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  6. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  7. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  8. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  9. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

随机推荐

  1. spring中使用HibernateTemplate或HibernateDaoSupport报类型转换错误

    使用spring的HibernateDaoSupport的时候.报错例如以下: java.lang.ClassCastException: java.lang.String cannot be cas ...

  2. linux下图片转换工具[【转】

    本文转载自:https://linux.cn/article-8014-1.html 计算机术语中,批处理指的是用一个非交互式的程序来执行一序列的任务的方法.这篇教程里,我们会使用 Linux 命令行 ...

  3. ES shrink ——一般是结合rollover一起使用的,一开始没有看懂官方shrink文档,当看了这个之后就明白了

    rollover Elasticsearch 从 5.0 开始,为日志场景的用户提供了一个很不错的接口,叫 rollover.其作用是:当某个别名指向的实际索引过大的时候,自动将别名指向下一个实际索引 ...

  4. C# 开放式并发冲突报错处理

    1.调用DataSet.GetChanges()获取数据源中改变的数据 var data = ViewData.GetChanges() as ReleaseData; 2.为新增的数据 data 加 ...

  5. 代码实现wordpress彩色标签云的最简单的方法

    首先在wordpress主题文件夹内找到并用编辑器打开 functions.php 文件,随意找个位置不到插到别的函数里,“?>” 之前加入以下代码: //彩色标签云 function colo ...

  6. Android 自定义控件之圆形扩散View(DiffuseView)

    实现效果 使用 属性方法 代码 源码下载 参考链接 实现效果 使用 XML中: <com.airsaid.diffuseview.widget.DiffuseView android:id=&q ...

  7. 转载:SoapUI之接口数据传递

    SoapUI之接口数据传递(TestCase.TestSuite传递) SoapUI之接口数据传递(step传递) SoapUI+Groovy做接口自动化测试 SoapUI中使用Conditional ...

  8. 知识工程.Vs.软件构架,框架,设计模式.

    软件工程-原文链接:http://tech.it168.com/a2009/0902/672/000000672853.shtml 此文章详细给出了软件设计的基本概念和用途,文章链接:http://w ...

  9. ML二:python批量修改文件名-测试KDTree

    (1):#批量修改文件名 import os import numpy as np import string import shutil prefix =''#单引号,前缀! sufix ='txt ...

  10. Python Tutorial笔记

    Python Tutorial笔记 Python入门指南 中文版及官方英文链接: Python入门指南 (3.5.2) http://www.pythondoc.com/pythontutorial3 ...