Fancy Mouse
- -|||
有质因子个数超过4个(可以相同)的就是牛数,否则就是弱数
#include<iostream>
#include
<cmath>
using namespace std;

int IsNiu(long n);
int main()
{
    
long n;
    
while(cin>>n)
    
{
        
if(IsNiu(n)) cout<<"Niu!"<<endl;
        
else cout<<"Ruo"<<endl;
    }

    
return 0;
}

int IsNiu(long n)
{
    
int m = (int)sqrt((double)n),p,flag = 1,temp;
    
for(temp=0;temp<3;temp++)
    
{
        
for(p=2;p<=m;p++)
            
if(n%p==0)
            
{
                flag
=0;
                n
/=p;
                
break;
            }

            
if(flag==1return 0;
            flag
=1;
    }

    
return n>1;
}
posted on 2005-10-22 02:32  Fancy Mouse  阅读(334)  评论(1编辑  收藏  举报