当前位置:网站首页>Template_ Judging prime_ Square root / six prime method

Template_ Judging prime_ Square root / six prime method

2022-07-04 20:06:00 This question AC sleep again

//  prescribing 
bool f( int n )
{
	if( n<=3 ) return n>1;
	
    for( int i=2;i<=n/i;i++ )
        if( n%i==0 ) return false;
    return true;
}

//  Six prime method 
bool f( int n )
{
    if( n<=3 ) return n>1;
    if( n%2==0 || n%3==0 ) return false;
    
    for( int i=5;i<=n/i;i+=6 )
        if( n%i==0 || n%(i+2)==0 ) return false;
    return true;
}

原网站

版权声明
本文为[This question AC sleep again]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207041714263940.html