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:艰难AC.... 说下我的方法和错误经验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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator