Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

好吧,觉得这个解法还行,忍不住留言~~

Posted by DestinyDesigner at 2009-05-09 01:23:00 on Problem 1142
开始是打表,由于是八位数,试了一下,不太现实。后来想到分治法来做,果然比较快,一次就过了。

主要是在求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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator