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

Total Submission(s): 5238    Accepted Submission(s): 2925

Problem Description
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are
summed and the process is repeated. This is continued as long as necessary to obtain a single digit.



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.



The Eddy's easy problem is that : give you the n,want you to find the n^n's digital Roots.
 
Input
The input file will contain a list of positive integers n, one per line. The end of the input will be indicated by an integer value of zero. Notice:For each integer in the input n(n<10000).
 
Output
Output n^n's digital root on a separate line of the output.
 
Sample Input
2
4
0
 
Sample Output
4
4
 

本题考查九余定理

#include<stdio.h>
int main(){
int n,i,a;
while(scanf("%d",&n),n)
{
a=n;
for(i=2;i<=n;i++)
a=a*n%9;
if(a==0)
printf("9\n");
else printf("%d\n",a);
}
return 0;
}

Eddy&#39;s digital Roots的更多相关文章

  1. HDU1163 Eddy&#39;s digital Roots【九剩余定理】

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

  2. Eddy's digital Roots

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

  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. HDOJ 1163 Eddy's digital Roots(九余数定理的应用)

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

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

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

  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. HDU——1163Eddy's digital Roots(九余数定理+同余定理)

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

  8. Digital Roots 1013

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

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

随机推荐

  1. 【BIT套主席树】COGS257-动态排名系统

    题意同BZOJ1901,多组数据,数据范围也不一样.重新写一遍复习一下. #include<iostream> #include<cstdio> #include<cst ...

  2. 初涉springboot(二)

    概述 1.环境说明 2.HelloWorld项目细节   3.小结 一. 关于环境补充 在上一篇的HellWorld项目中,我们构建SpringBoot项目,采用的是jdk1.8版本,springbo ...

  3. uoj117 欧拉回路

    题目描述: 有一天一位灵魂画师画了一张图,现在要你找出欧拉回路,即在图中找一个环使得每条边都在环上出现恰好一次. 一共两个子任务: 这张图是无向图.(50 分) 这张图是有向图.(50 分) 输入格式 ...

  4. TJU 2248. Channel Design 最小树形图

    最小树形图,測模版.... 2248.   Channel Design Time Limit: 1.0 Seconds   Memory Limit: 65536K Total Runs: 2199 ...

  5. Surface Mount Package Details

    http://www.centralsemi.com/product/packages/index2.php http://www.infineon.com/cms/cn/product/packag ...

  6. C# WebHelper-CookieHelper,CacheHelper,SessionHelper

    常用web操作工具类,记录一下,本文记录的工具类,都要求引用 System.Web 1.CookieHelper /// <summary> /// Cookie工具类 /// </ ...

  7. 解决 Operation must use an updateable query

    在asp.net 开发环境下,用jet 4.0连接access数据库, 有时会产生Operation must use an updateable query,这是由于相关用户mdb文件没有Modif ...

  8. 空间索引网格大小无效的解决方法The spatial index grid size is invalid

    原名引至:http://www.cnblogs.com/linhugh/archive/2012/07/24/2606439.html   之前在做shp数据导入Geodatabase中时,程序运行出 ...

  9. 如何将Emmet安装到Notepad++?

    1.下载Notepad++插件;(zen-Coding for Notepad++)2.解压后将压缩包中的文件放入Notepad++安装目录下的plugins文件夹中;3.重新启动就能看到菜单栏上增加 ...

  10. Guava的使用

    package guava; import java.io.File; import java.io.IOException; import java.util.ArrayList; import j ...