Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Digit roothttp://en.wikipedia.org/wiki/Digital_root As S(n)=n-9 * ⌊n/9⌋ => S(n) mod 9 = n mod 9 And S(n) = (N1+N2+…Ni+…) (Ni means the digit of n) => dr(n)=n mod 9=S(n) mod 9=(N1+N2+…Ni+…) mod 9 (S(n) mod 9 ≠0), dr(n) = 9 (S(n) mod 9 = 0) Then we can get the algorithm (n ≠0) For Ni:N tmp = (Ni + tmp) mod 9 if tmp equals 0 dr(n) = 9 else dr(n)=tmp Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator