HDU1163 Eddy's digital Roots【九剩余定理】
Eddy's digital Roots
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.
2
4
0
4
4
九余数定理:一个数对9取余所得为九余数。一个数的九余数等于该数的各位和对9取余。
#include <stdio.h> int main()
{
int n, i, ans;
while(scanf("%d", &n), n){
ans = 1;
for(i = 1; i <= n; ++i)
ans = n * ans % 9;
if(!ans) ans = 9;
printf("%d\n", ans);
}
return 0;
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
HDU1163 Eddy's digital Roots【九剩余定理】的更多相关文章
- Eddy's digital Roots
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission ...
- HDU-1163Eddy's digital Roots,九余定理的另一种写法!
下午做了NYOJ-424Eddy's digital Roots后才正式接触了九余定理,不过这题可不是用的九余定理做的.网上的博客千篇一律,所以本篇就不发篇幅过多介绍九余定理了: 但还是要知道什么是九 ...
- HDOJ 1163 Eddy's digital Roots 九余数定理+简单数论
我在网上看了一些大牛的题解,有些知识点不是太清楚, 因此再次整理了一下. 转载链接: http://blog.csdn.net/iamskying/article/details/4738838 ht ...
- HDU-1163 Eddy's digital Roots(九余数定理)
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDOJ 1163 Eddy's digital Roots(九余数定理的应用)
Problem Description The digital root of a positive integer is found by summing the digits of the int ...
- Eddy's digital Roots(九余数定理)
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- Eddy's digital Roots
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- HDU 1163 Eddy's digital Roots
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDU——1163Eddy's digital Roots(九余数定理+同余定理)
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
随机推荐
- 全民Scheme(0):lat的定义
接下来我会写一写Scheme的学习笔记.嗯,Scheme是属于小众的语言,但合适用来教学的. 什么是lat,就是遍历list里的每一个S-expression,假设发现当中某个不是atom的,则返回f ...
- hadoop format过程
private static boolean format(Configuration conf, boolean isConfirmationNeeded ) throws IOException ...
- anthelion编译
编程工程 $ cd ./anthelion/anthelion/target/classes$ java -Xmx15G -cp ../Anthelion-1.0.0-jar-with-depende ...
- Delphi VMT的前世今生(研究一下D7的VMT表结构)
主要是TObject那些虚函数,到底放在了哪里?
- [Cocos2d-x学习笔记]Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk解决方案
Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawkawk过期网上 ...
- jquery中实现全选按钮
<html> <head> <script type='text/javascript' src='js/jquery-1.5.1.js'></scr ...
- 《sql---教学反馈系统-阶段项目1》
--修改列 --把 "Address" 栏位改名为 "Addr".这可以用以下的指令达成: --ALTER table customer change Addr ...
- 一致性哈希算法(consistent hashing)样例+測试。
一个简单的consistent hashing的样例,非常easy理解. 首先有一个设备类,定义了机器名和ip: public class Cache { public String name; pu ...
- OpenGL--第一个OpenGL程序
环境:VS2012 + OpenGL所需文件(其他IDE也可以,不一定要VS2012,VS2010或其他也可以) 步骤: 1.下载Vs2012 2.下载OpenGL所需文件 3.解压缩OpenGL包并 ...
- hdoj 1258 SUM IT UP
程序的思想是:输入数据是,先使用快排对其从大到小进行排序,然后记录相同数据的个数,比如4 3 3 2 2 1 1,最后的数据变成4 3 2 1 ,并且同时数据的个数f[]变成1 2 2 2 然后就是遍 ...