| ||||||||||
| 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 | |||||||||
我是这样搞地~~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