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 ...
随机推荐
- FileReader读取文件里文乱码问题
有一个UTF-8编码的文本文件,用FileReader读取到一个字符串,然后转换字符集:str=newString(str.getBytes(),"UTF-8");结果大部分中文显 ...
- Java按钮设计
package com.han; import javafx.application.Application; import javafx.geometry.Insets; import javafx ...
- MVVM Light须要注意的10个问题
MVVM Light须要注意的10个问题 从使用XAML技术基础開始(实际上并非非常久曾经).我便关注MVVM(Model – View – ViewModel)模式.偶然接触到MVVM Light不 ...
- VLC笔记 它 立志
不过,别忘了找工作的时候毕业,我说:"至少不会操心你会饿死了". 直到刚刚我才认为我妈有点过于乐观了. 今天下午,在做vlc如今播放器部分,一堆代码看的我头大. 正在此时,boss ...
- A Game of Thrones(12) - Eddard
The summons(['sʌm(ə)nz]召唤:传票) came in the hour before the dawn, when the world was still and grey. A ...
- [WPF]使用Pack URI路径訪问二进制资源
一.路径格式定义 完整的URI定义为: pack://application,,,[/可选程序集名称;][可选版本;][目录名称/]文件名 缩略后的写法是: [目录名称/]文件名 二.在XAML代码中 ...
- 京东商城招聘scala 高级开发工程师 T3级别
岗位级别:T3 岗位职责: 1.参与自动调价.匹配系统的设计和实现 岗位要求: 1. 一年以上scala开发经验2.良好的函数式编程能力3. JAVA基础扎实4.熟悉大数据处理,有hadoop/hba ...
- Android利用Get、Post 获取网络数据
首先是Get: 布局非常easy.就一个button,主要看一下MainActivity吧: package com.francis.httpget; import android.app.Activ ...
- Using OpenCV Java with Eclipse(转)
转自:http://docs.opencv.org/trunk/doc/tutorials/introduction/java_eclipse/java_eclipse.html Using Open ...
- 压缩js参数保存解决方法
angular.js 中 找到 if (typeof fn === 'function') 在 if (fn.length) { console.warn("此函数没有注入注解,将导致编译 ...