有质因子个数超过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==1) return 0;
flag=1;
}
return n>1;
}
#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==1) return 0;
flag=1;
}
return n>1;
}