hdu-1163(九余数定理)】的更多相关文章

Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5928    Accepted Submission(s): 3270 Problem Description The digital root of a positive integer is found by summing the digit…
http://acm.hdu.edu.cn/showproblem.php?pid=1163 九余数定理: 如果一个数的各个数位上的数字之和能被9整除,那么这个数能被9整除:如果一个数各个数位上的数字之和被9除余数是几,那么这个数被9除的余数也一定是几. 证明: 首先10^i =99...9(i个9) +1除以9的余数=1 所以ai*10^i除以9的余数=ai 用a0~an表示各位数字则数=(anan-1an-2.a2a1a0), =an*10^n+an-1*10^n-1 +an-2 *10^n…
我在网上看了一些大牛的题解,有些知识点不是太清楚, 因此再次整理了一下. 转载链接: http://blog.csdn.net/iamskying/article/details/4738838 http://www.2cto.com/kf/201405/297531.html 题目描述:求n^n次的digital root(数根),例如root(67)=6+7=root(13)=1+3=4; 一类解法: 求解思路:现在分析一个问题,假设将十位数为a,个位数为b的一个整数表示为ab,则推导得ab…
Problem Description The digital root of a positive integer is found by 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 a…
1.HDU1013求一个positive integer的digital root,即不停的求数位和,直到数位和为一位数即为数根. 一开始,以为integer嘛,指整型就行吧= =(too young),后来大数自然用字符串解决,然后get到一个新数论点九余数定理: https://en.wikipedia.org/wiki/Digital_root 即:一个数的数根等于它模 9 的余数.(=>几个数之积的九余数=每个数的九余数之积的九余数.) 2.HDU1163,2035求n^n的数根,即九余…
Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 64420    Accepted Submission(s): 20053 Problem Description The digital root of a positive integer is found by summing the digits of…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1163 思路: 九余数定理:一个数对九取余的结果叫做九余数, 一个数的各个位数相加的得到的小于10的数也叫九余数 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int main(void) { int n,tp,i; while(~scanf("%d",…
HDU 1163 题意简单,求n^n的(1)各数位的和,一旦和大于9,和再重复步骤(1),直到和小于10. //方法一:就是求模9的余数嘛! (228) leizh007 2012-03-26 21:03:19 (确实可行) #include<stdio.h> #include<string.h> int main() { int n,i,ans; while(scanf("%d",&n),n) { ans=; ;i<n;i++) { ans=(a…
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 Problem Description The digital root of a positive integer is found by summing the digit…
Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4632    Accepted Submission(s): 2578 Problem Description The digital root of a positive integer is found by summing the digi…