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. loj117 有源汇有上下界最小流

    link 题意&题解 code: #include<bits/stdc++.h> #define rep(i,x,y) for (int i=(x);i<=(y);i++) ...

  2. mac安装redis拓展

    安装 下载源码 编译安装 添加拓展 添加权限重启 安装 在mac上安装了php7.1.7 php -m 查看安装的拓展,没有redis,以前可以brew install php71-redis简单命令 ...

  3. SpringMVC 常用注解 详解

    SpringMVC 常用注解 详解 SpringMVC 常用注解 1.@RequestMapping                                      路径映射 2.@Requ ...

  4. const和define在值定义上的区别

    (1) 编译器处理方式不同 define宏是在预处理阶段展开. const常量是编译运行阶段使用. (2) 类型和安全检查不同 define宏没有类型,不做任何类型检查,仅仅是展开. const常量有 ...

  5. bzoj 2440

    题意:有一个从小到大的由不包含平方约数的数组成的数列,从1开始,求第k项. “满足某种限制的数的第k个”+二分答案="前n个数有多少个数满足限制“ 求[1,n]中有多少个数没有平方约数,我们 ...

  6. mySql---logback日志写入数据库(mysql)配置

    如题  建议将日志级别设置为ERROR.这样可以避免存储过多的数据到数据中. 1  logback 配置文件(如下) <?xml version="1.0" encoding ...

  7. Ehcache缓存时间设置

    timeToLiveSeconds和timeToIdleSecondstimeToLiveSeconds=x:缓存自创建日期起至失效时的间隔时间x:timeToIdleSeconds=y:缓存创建以后 ...

  8. Linux下添加静态路由表设置网关出现SIOCADDRT: Network is unreachable的问题分析

    场景: # route add default gw 192.168.4.1 route: SIOCADDRT: Network is unreachable 解释: 1.先ping一下网关,但是pi ...

  9. Dual-polarity supply provides ±12V from one IC

    LT1961 升压型稳压器造就了兼具升压和降压能力的扁平状SEPIC Transformerless dc/dc converter produces bipolar outputs Well-reg ...

  10. 【转】2012年6月25 – 某欧美上市企业PHP工程师最新面试题

    笔试: 尼玛,连页眉页脚都是英文!不过都还能读懂.题目很简单.印象深刻的有几题. 具体题目忘了,主要知识点考点是,建立的视图,实现有自增字段. 答:之前还真没考虑过这个问题.当时条件发射,给了一个用户 ...