您的位置:首页 > 其它

lightoj1220Mysterious Bacteria

2016-05-19 00:47 288 查看
sb题,你可以

1.暴力n−−√枚举因子

2.枚举答案,判是否可行

hint:注意负数

#include <stdio.h>
#include<cmath>
#include<cstring>
using namespace std;
typedef  long long LL;
LL solve(LL n){
int flag=0;
if(n<0){n=-n,flag=1;}
LL mx=sqrt(n);
for(LL i=2;i<=mx;i++){
LL ts=n,cnt=0;
while(ts%i==0){
ts/=i;
cnt++;
}
if(ts==1){
if(!flag)return cnt;
else if(cnt&1) return cnt;
}
}
return 1;
}
int main(void)
{
int t,cas=0;
scanf("%d",&t);
while(t--){
LL n;
scanf("%lld",&n);
printf("Case %d: %lld\n",++cas,solve(n));
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lightoj 数学