Eddy's digital Roots
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4793 Accepted Submission(s): 2672
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.
4
0
思路:1.九余数定理 一个数的n的树根=(n-1)%9+1
2.N个整数的树根的乘机总值=每个项元素的树根的乘积
3.分步求余
#include<cstdio>
#include<cmath>
int main()
{
int n;
while(scanf("%d",&n)&&n)
{
int m=n;
int i;
int ans=;
m=(m-)%+;//先把底数m求树根,根据 N个整数的乘积带的树根=每项元素的树根的乘积
for(i=;i<=n;i++)
ans=(ans*m-)%+;//分步求余
printf("%d\n",ans);
}
}
Eddy's digital Roots的更多相关文章
- HDU 1163 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(九余数定理)
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 ...
- HDOJ 1163 Eddy's digital Roots 九余数定理+简单数论
我在网上看了一些大牛的题解,有些知识点不是太清楚, 因此再次整理了一下. 转载链接: http://blog.csdn.net/iamskying/article/details/4738838 ht ...
- HDU 1163 Eddy's digital Roots(模)
HDU 1163 题意简单,求n^n的(1)各数位的和,一旦和大于9,和再重复步骤(1),直到和小于10. //方法一:就是求模9的余数嘛! (228) leizh007 2012-03-26 21: ...
- hdu 1163 Eddy's digital Roots 【九余数定理】
http://acm.hdu.edu.cn/showproblem.php?pid=1163 九余数定理: 如果一个数的各个数位上的数字之和能被9整除,那么这个数能被9整除:如果一个数各个数位上的数字 ...
- HDU1163 - Eddy's digital Roots
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1163 九余数:一个数除于9所得到的余数,即模9得到的值 求九余数: 求出一个数的各位数字之和,如果是两 ...
- HDU1163 Eddy's digital Roots【九剩余定理】
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
随机推荐
- Python列表基础
==========列表基础=========== 列表中的数据是可以被修改的.字典,元组,集合是不能被修改的. >>> li1=['3edf','dafdas'] >> ...
- 通过rails console执行sql语句
$ RAILS_ENV=production bundle exec rails c irb(main):008:0> r = ActiveRecord::Base.connection.exe ...
- 关于seajs
(这些文章都是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 最近经常听到各种JS前缀的名称,瞬间感觉自己弱爆了,啥都没用过呢,这么下去将来怎么嫁人呢. ...
- meanshift和camshift
参考:http://www.cnblogs.com/tornadomeet/archive/2012/03/15/2398769.html 照着这位大神的代码运行了一下,发现meanshift的跟踪效 ...
- 国内常用NTP服务器地址及IP
iptables实现80端口转发到8080端口上 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 ...
- Longest Substring with At Most K Distinct Characters
Given a string, find the longest substring that contains only two unique characters. For example, gi ...
- sharepoint更新多行文本webparth
前台 <script> function Copy() { var value = document.getElementById("<%=BodyBox.ClientID ...
- Dom lesson1
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- IOS多线程(GCD)
简介 Grand Central Dispatch 简称(GCD)是苹果公司开发的技术,以优化的应用程序支持多核心处理器和其他的对称多处理系统的系统.这建立在任务并行执行的线程池模式的基础上的.它首次 ...
- Servlet、JSP选择题(2)
Java EE软件工程师认证考试 试题库-选择题 一. 选择题(包括单选和双选) 1.B 编写一个Filter,需要( ) A. 继承Filter 类 B. 实现Filter 接口 C. 继承 ...