light oj 1220 Mysterious Bacteria
来源:互联网 发布:二次视频解析接口源码 编辑:程序博客网 时间:2024/05/20 21:43
Mysterious Bacteria
Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction system. RC-01 lives exactlyx days. Now RC-01 produces exactlyp new deadly Bacteria wherex = bp (whereb, p are integers). More generally,x is a perfectpth power. Given the lifetimex of a mother RC-01 you are to determine the maximum number of new RC-01 which can be produced by the mother RC-01.
Input starts with an integer T (≤ 50), denoting the number of test cases.
Each case starts with a line containing an integerx. You can assume thatx will have magnitude at least 2 and be within the range of a 32 bit signed integer.
For each case, print the case number and the largest integerp such thatx is a perfect pth power.
3
17
1073741824
25
#include<iostream>#include<algorithm>#include<cmath>#include<cstdio>#include<queue>#include<cstring>#include<string>#include<map>#include<set>using namespace std;typedef long long ll;#define for1(i,a) for(int (i)=1;(i)<=(a);(i)++)#define for0(i,a) for(int (i)=0;(i)<(a);(i)++)#define sf scanf#define pf printf#define mem(i,a) memset(i,a,sizeof i)#define pi acos(-1.0)#define eps 1e-10const int Max=1e6+7;int p[Max+1],cou,n,T;ll m;bool vis[Max+1];void prime()//素数打表{ cou=0; mem(vis,0); for(int i=2;i<=Max;i++) { if(!vis[i])p[cou++]=i; for(int j=0;j<cou&&(ll)i*p[j]<=Max;j++) { vis[i*p[j]]=1; if(!(i%p[j]))break; } }}int GCD(int x,int y)//求最大公约数{ return !y?x:GCD(y,x%y);}int main(){ prime(); sf("%d",&T); for1(i,T) { sf("%lld",&m); int tag=1; if(m<0)tag=0,m=-m; int ans=0; for(int j=0;j<cou&&p[j]<=sqrt(m);j++)//唯一分解 { int num=0; if(!(m%p[j])) while(!(m%p[j])) num++,m/=p[j]; if(!ans)ans=num;//对ans赋初值 else ans=GCD(ans,num);//对分解的因式的次数求GCD } if(m>1)ans=1; if(!tag)//n小于0的情况要将偶数次幂除去 while(!(ans%2)) ans>>=1; pf("Case %d: %d\n",i,ans); } return 0;}
- light oj 1220 Mysterious Bacteria
- [整数分解+dfs] light oj 1220 Mysterious Bacteria
- lightOJ 1220 Mysterious Bacteria
- LightOJ 1220 Mysterious Bacteria
- (LightOJ 1220)Mysterious Bacteria
- LightOJ 1220 Mysterious Bacteria
- LightOJ 1220 Mysterious Bacteria
- LightOJ 1220 Mysterious Bacteria
- lightOJ 1220 Mysterious Bacteria
- lightOJ 1220 Mysterious Bacteria
- lightoj 1220 - Mysterious Bacteria 【数学】
- lightoj 1220 - Mysterious Bacteria 【数学】
- Mysterious Bacteria ( lightOJ 1220)
- Mysterious Bacteria
- Mysterious Bacteria
- LightOj 1220 Mysterious Bacteria(数论)
- LightOj Mysterious Bacteria
- Mysterious Bacteria LightOJ
- oracle 执行计划
- 安装了JDK1.8 但在eclipse-jee-kepler-SR1-win32-x86_64中最高版本只为1.7
- gulp总结
- [bzoj2400]Spoj 839 Optimal Marks 最小割
- 数据库的基础知识
- light oj 1220 Mysterious Bacteria
- [差分约束]POJ 3159——Candies
- docker network
- 70%以上业务由H5开发,手机QQ Hybrid 的架构如何优化演进?
- 文件下载/导出
- ActiveMQ错误:Wire format negotiation timeout: peer did not send his wire format
- navicat 10.1.7 注册码
- sklearn库之各分类算法简单应用
- Python os 和 os.path模块详解