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. 在MySQL字段中使用逗号分隔符

    大多数开发者应该都遇到过在mysql字段中存储逗号分割字符串的经历,无论这些被分割的字段代表的是id还是tag,这个字段都应该具有如下几个共性. 被分割的字段一定是有限而且数量较少的,我们不可能在一个 ...

  2. ElasticSearch学习笔记--1、安装以及运行

    Elasticsearch是一个基于Apache Lucene(TM)的开源搜索引擎,多的我就不细说了. 相关实验环境 Centos:7.3 ElasticSearch:5.6 java:1.8 1. ...

  3. org.apache.curator:master选举和分布式锁

    1. master选举(LeaderSelector) 1)LeaderSelector构造函数 在leaderPath上建立分布式锁:mutex = new InterProcessMutex(cl ...

  4. Javascript中的异步

    在C#,Java中,异步方法,通常是伴随多线程,并发等术语一起出现的,比如C#中的async方法,是运行在一个线程池线程上,并且在异步方法运行完成后,有一个回调函数通知主线程. 那么由于Javascr ...

  5. InvalidateRect()与Invalidate()的用法(转)

    BOOL InvalidateRect(   HWND hWnd,           // 窗口句柄   CONST RECT* lpRect,   // 矩形区域   BOOL bErase    ...

  6. iOS学习之sqlite的创建数据库,表,插入查看数据

    目录(?)[-] 新建项目sqliteDemo添加使用sqlite的库libsqlite3dylib sqlite 的方法 获取沙盒目录并创建或打开数据库 创建数据表 插入数据 查询数据库并打印数据 ...

  7. ionic开发环境搭建之ios

    前言 公司在做完ionic androud版后就开始做ios版,虽然ios的坑我觉得比起androud少了很多,但是作为第一次接触ios的我来说,环境实在太麻烦,从搭环境到打包一个正式版的ios ap ...

  8. OAuth:OAuth概述

    OAuth addresses these issues by introducing an authorization layer and separating the role of the cl ...

  9. [转] NSMapTable 不只是一个能放weak指针的 NSDictionary

    NSMapTable 不只是一个能放weak指针的 NSDictionary NSMapTable是早在Mac OS X 10.5(Leopard)的引入集合类.乍一看,这似乎是作为一个替换NSDic ...

  10. Orchard运用 - 为评论启用Gravatar头像

    在前一篇随笔中我曾分享如何为Orchard特定主题添加独立代码文件, 今儿延续如何把对应代码应用到Views上. 对此我不妨把为评论启用Gravatar头像这一例子来实现.其实很简单, 思路大概就是创 ...