LightOJ 1220 Mysterious Bacteria
2016-09-11 16:41
1856 查看
1220 - 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 exactly x days. Now RC-01 produces exactly p new deadly Bacteria where x = bp (where b,
p are integers). More generally, x is a perfect pth power. Given the lifetime x 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.
Each case starts with a line containing an integer x. You can assume that x will have magnitude at least 2 and be within the range of a 32 bit signed integer.
PROBLEM SETTER: MUHAMMAD RIFAYAT SAMEE
SPECIAL THANKS: JANE ALAM JAN
题意:求满足x=b^p 的最大的p的值
思路:暴力
PDF (English) | Statistics | Forum |
Time Limit: 0.5 second(s) | Memory Limit: 32 MB |
p are integers). More generally, x is a perfect pth power. Given the lifetime x 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
Input starts with an integer T (≤ 50), denoting the number of test cases.Each case starts with a line containing an integer x. You can assume that x will have magnitude at least 2 and be within the range of a 32 bit signed integer.
Output
For each case, print the case number and the largest integer p such that x is a perfect pth power.Sample Input | Output for Sample Input |
3 17 1073741824 25 | Case 1: 1 Case 2: 30 Case 3: 2 |
PROBLEM SETTER: MUHAMMAD RIFAYAT SAMEE
SPECIAL THANKS: JANE ALAM JAN
题意:求满足x=b^p 的最大的p的值
思路:暴力
#include<stdio.h> #include<string.h> #include<algorithm> #define LL long long using namespace std; struct node { int num; int time; }p[60]; int k; void get(LL n)//分解质因子 { k=0; for(LL i=2;i*i<=n;i++) { if(n%i==0) { p[k].num=i; int cnt=0; while(n%i==0) { n=n/i; cnt++; } p[k++].time=cnt; } } if(n>1) { p[k].num=n; p[k++].time=1; } } bool judge(int x) { for(int i=0;i<k;i++) { if(p[i].time%x) return false; } return true; } int main() { int t,m,x,i,j,cnt=1; LL n; scanf("%d",&t); while(t--) { scanf("%lld",&n); bool flag=false; if(n<0)//注意 { n=-n; flag=true; } get(n); int ans; if(flag) { for(i=32;i>=1;i--) { if(judge(i)&&i&1) { ans=i; break; } } } else { for(i=32;i>=1;i--) { if(judge(i)) { ans=i; break; } } } printf("Case %d: %d\n",cnt++,ans); } return 0; }
相关文章推荐
- LightOJ - 1220(n=b^k时最大的k,GCD)
- LightOJ 1220
- LightOJ-1220 Mysterious Bacteria 唯一分解定理 带条件的最大公因数
- LightOJ - 1220
- LightOJ 1220 Mysterious Bacteria(唯一分解定理 + 素数筛选)
- LightOJ 1220 Mysterious Bacteria
- LightOJ-1220
- lightOJ 1220 Mysterious Bacteria
- LightOj 1220 - Mysterious Bacteria (分解质因子x=b^p 中的 x 求最大的 p)
- Mysterious Bacteria LightOJ - 1220 (唯一分解定理,gcd)
- LightOJ - 1220 Mysterious Bacteria 唯一分解定理
- lightOJ 1220 Mysterious Bacteria
- LightOJ 1220 - Mysterious Bacteria(唯一分解定理)
- LightOJ 1220 Mysterious Bacteria(满足a^p = n的最大p)
- 1220 - Mysterious Bacteria--LightOj1220 (gcd)
- LightOJ - 1220 Mysterious Bacteria (唯一分解定理)
- kuangbin专题十四 LightOJ1220 分解质因数
- [唯一分解定理] LightOJ 1220
- LightOJ 1220 - Mysterious Bacteria (质因子分解)
- lightoj 1220 - Mysterious Bacteria 【数学】