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 ...
随机推荐
- linux下tar用法
以下是linux下tar的用法,转一下,以便方便自己看(这里没把rar,zip类的转过来,一般rar,zip在linux下基本没人用,基本上是zip,unzip,rar,unrar,这些命令,并且ra ...
- Django uplodify 多文件同时上传
Js代码: //批量上传按钮 $('#fileupload').uploadify ({ 'swf' : '/CoveragePlaform/media/uploadify-3.2/uploadify ...
- Qt Quick - 开启下一代交互动效原型设计(效果很美,相关系列博文)
http://blog.csdn.net/unixzii/article/details/46501265
- python实现词法分析
#请先安装Ply # -*- coding: utf-8 -*- #------------------------------------------------------------------ ...
- IOS 掉用系统发短信
#import <MessageUI/MessageUI.h> MFMessageComposeViewControllerDelegate #pragma mark - 调用ios系统短 ...
- IOS 排序算法
/** * @brief 冒泡排序法 * * @param arr 需要排序的数组 */ -(void)BubbleSort:(NSMutableArray *)arr { // 取第一个与其邻接的对 ...
- LeetCode——Reverse Words in a String
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue ...
- static_cast
C 风格(C-style)强制转型例如以下: (T) exdivssion // cast exdivssion to be of type T 函数风格(Function-style)强制转型使用这 ...
- [python笔记][第二章Python序列-list]
2016/1/27学习内容 第二章 Python序列-list list常用操作 list.append(x) list.extend(L) list.insert(index,x) list.rem ...
- 【贪心】【Uva11292】 勇者斗恶龙
直接用白书上的翻译吧 例题1 勇者斗恶龙(The Dragon of Loowater, UVa 11292) 你的王国里有一条n个头的恶龙,你希望雇一些骑士把它杀死(即砍掉所有头).村里有m个骑士 ...