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:18014398509481931In Reply To:我是这样搞地~~ Posted by:achilles at 2004-08-30 17:35:48 > llong is_prime(llong n) > { > llong old = n; > if (n%2 == 0) > return 2; > > llong limit = llong(sqrt(n*1.0)) + 1; > if (limit%2 == 0) --limit; > > do{ > if (n%limit == 0) > { > n = limit; > limit = llong(sqrt(n*1.0))+1; > if (limit%2 == 0) --limit; > } > else > limit -= 2; > }while (limit >= 3); > if (old == n) > return 1; > else > return n; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator