Eddy's digital Roots(九余数定理)
Eddy's digital Roots
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5113 Accepted Submission(s):
2851
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.
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.
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,sum,i;
while(cin>>n&&n)
{
sum=;
i=n;
while(i--)
sum=(sum*n)%;
if(sum==)
cout<<<<endl;
else
cout<<sum<<endl;
}
return ;
}
Eddy's digital Roots(九余数定理)的更多相关文章
- HDOJ 1163 Eddy's digital Roots 九余数定理+简单数论
我在网上看了一些大牛的题解,有些知识点不是太清楚, 因此再次整理了一下. 转载链接: http://blog.csdn.net/iamskying/article/details/4738838 ht ...
- Hdu1163 Eddy's digitai Roots(九余数定理)
题目大意: 给定一个正整数,根据一定的规则求出该数的“数根”,其规则如下: 例如给定 数字 24,将24的各个位上的数字“分离”,分别得到数字 2 和 4,而2+4=6: 因为 6 < 10,所 ...
- 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 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 ...
- hdu 1163 Eddy's digital Roots 【九余数定理】
http://acm.hdu.edu.cn/showproblem.php?pid=1163 九余数定理: 如果一个数的各个数位上的数字之和能被9整除,那么这个数能被9整除:如果一个数各个数位上的数字 ...
- 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-1013-Digital Roots(九余数定理)
题目链接 #include <iostream> using namespace std; int main() { string a; int b; ") { b = ; ;i ...
随机推荐
- 读jquery.cookie.js源码学到的几个技巧
一.兼容AMD.CommonJS和普通JS的写法 (function (factory) { if (typeof define === 'function' && define.am ...
- CI(CodeIgniter)学习第二讲
一.CI的文件结构: 了解CI的文件结构可以帮助我们快速的对CI框架有一个整体的认识,就好像我们去了一个陌生的城市一样,对你来讲周围的一切都是陌生和未知的,要想快速的了解这座城市,你可以买一张这座城市 ...
- 【0】python核心编程,第二章
1.print语句也支持将输入重定向到文件,示例: logfile = open('/tmp/mylog.txt', 'a') print >> logfile, 'Fatal error ...
- NOI十连测 第四测 T2
思路:线段树套可持久化treap,可持久化treap我还是第一次听说.. 改题的时候没看数据范围..乱开数组T_T #include<algorithm> #include<cstd ...
- javascript调试
今天,发现了一个之前从未注意的角落,相信能够大大提高自己写JS的速度.能够迅速发现错误. 例如,今天的加班中调试一个js错误发现的一个例子. 1.Google浏览器报的错 以上是google浏览器报的 ...
- HtmlAgilityPack - 简介
HtmlAgilityPack是.net下的一个HTML解析类库.支持用XPath来解析HTML.这个意义不小,为什么呢?因为对于页面上的元素的xpath某些强大的浏览器能够直接获取得到,并不需要手动 ...
- Binary Search Tree Iterator 解答
Question Implement an iterator over a binary search tree (BST). Your iterator will be initialized wi ...
- linux 下apache安装、启动和配置
linux 下 apache安装 1:系统安装,这里就不说了,网上有很多,也很简单.顺便说下,我用的是redhat 9: 2:在图形界面下下载apache 安装包,我下的是 httpd-2.2.9.t ...
- 【点击模型学习笔记】Predicting Clicks_Estimating the Click-Through Rate for New Ads_MS_www2007
概要: 微软研究院的人写的文章,提出用逻辑回归来解决ctr预估问题,是以后ctr的经典解决方式,经典文章. 详细内容: 名词: CPC -- cost per click CTR -- click t ...
- 【剑指offer】Q40:数组中出现一次的数
书里面关于分类的推断有些麻烦,通过某一位为0为1来对数组元素进行分类.假如第3位为1.那么也就是元素x & 8 等于或不等于0,所以不是必需非的用第几位去推断. def once(array) ...