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

Re:艰难AC.... 说下我的方法和错误经验

Posted by huangchang9001 at 2011-04-18 22:24:31 on Problem 1142
In Reply To:艰难AC.... 说下我的方法和错误经验 Posted by:xuchang at 2011-02-24 15:35:52
我不是大牛,不过可以不用判断x是否为素数,用一函数求x是否为Smith 数,sum为x中数字的和,a=2 to sqrt(x);
如果x%a==0 return dfs(x/a,a,s,sum),s为a中数字的和,
如果循环到a=sqrt(x)+1 则 return 0
dfs(X,A,s,sum)中a=A (直接跳过前面已经被除的小与A的素数)to sqrt(X) 
如果x%a==0 return dfs(x/a,a,s+k,sum),k为a中数字的和
如果循环到a=sqrt(X)+1,求k(k为X中数字的和),如果k+s==sum return 1 反之return 0
32ms不过比那些0ms的大牛还差点距离!

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