• LightOJ


    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.


    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
    3
    17
    1073741824
    25
    Sample Output
    Case 1: 1
    Case 2: 30

    Case 3: 2

    #include<stack>
    #include<queue>
    #include<math.h>
    #include<vector>
    #include<string>
    #include<stdio.h>
    #include<map>
    #include<iostream>
    #include<string.h>
    #include<algorithm>
    #define maxn 1000005
    #define maxm 10000005
    #define MAXN 100005
    #define MAXM 10005
    #define mem(a,b) memset(a,b,sizeof(a))
    #define ll long long
    #define inf 0x3f3f3f3f
    using namespace std;
    bool vis[maxm+5];
    ll tot;
    ll p[maxn];
    void get_prime(){
         tot=0;
        mem(vis,true);
        for(ll i=2;i<=maxm;i++){
            if(vis[i]){
                p[tot++]=i;
                for(ll j=i*i;j<=maxm;j+=i)vis[j]=false;
            }
        }
    }
    int main(){
        get_prime();
        int t,test=0;
        scanf("%d",&t);
        while(t--){
         ll n;scanf("%lld",&n);
         ll m=n;
         n=abs(n);
         ll x=0,ans=-1;
         while(p[x]<=n&&x<tot){
            ll y=0;
            while(n%p[x]==0){y++;n/=p[x];}
            x++;
            if(ans==-1)ans=y;
            else
                ans=__gcd(ans,y);
         }
         if(n>1)ans=__gcd(ans,(ll)1);
         if(m<0){
            while(ans%2==0)ans/=2;
         }
         else if(m==1||m==0)
            ans=1;
            printf("Case %d: %lld
    ",++test,ans);
        }
    }

  • 相关阅读:
    H50055:html 页面加载完后再加载js文件 ,url带有时间戳后缀
    H50054:html 页面自动刷新 http-equiv属性
    WebGL_0015:参数值在一定范围内循环变化
    H50053:switch 判断范围
    WebGL_0014:改变相机的刷新颜色
    WebGL_0013:JQuery获取json文件 读取数据
    WebGL_0012:三维讲解导航模板 Icon方式
    H50052:按钮 禁止 选择 拖拽 右键
    滑动窗口的最大值(队列)
    MapReduce程序编写过程
  • 原文地址:https://www.cnblogs.com/da-mei/p/9053223.html
Copyright © 2020-2023  润新知