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 |
Re:好吧,觉得这个解法还行,忍不住留言~~In Reply To:好吧,觉得这个解法还行,忍不住留言~~ Posted by:DestinyDesigner at 2009-05-09 01:23:00 > 开始是打表,由于是八位数,试了一下,不太现实。后来想到分治法来做,果然比较快,一次就过了。 > > 主要是在求n的因子的时候用分治法就行了,还不用打表。 > > > //分治 > int cut(int n) > { > if(isprime(n)) > return digit_sum(n); > for(int i = (int) sqrt(1.0*n); i >= 2; i--) { > if(!(n%i)) > return cut(i) + cut(n / i); > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator