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:暴力刚刚过,800多毫秒~~

Posted by tanghaibao at 2008-12-28 22:49:26 on Problem 3006
In Reply To:暴力刚刚过,800多毫秒~~ Posted by:beyonlin_SCUT at 2007-03-29 20:23:33
110ms
bool is_prime(int n)
{
    if (n==1) return false;
    if (n==2||n==3) return true;
    if (n%2==0) return false; 
    if (n%3==0) return false; 
    int i;
    for (i=6;(i-1)*(i-1)<=n;i+=6)
    {
        if (n%(i-1)==0) return false;
        if (n%(i+1)==0) return false;
    }
    return true;
}

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