暴力就行了,找出素因子,正的最多是30,然后负的最多是31(这一点wa了一次)

#include <cstdio>
#include <iostream>
#include <ctime>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const int N=5e4+;
const int INF=0x3f3f3f3f;
bool v[N];
int prime[],cnt;
void getprime(){
for(int i=;i*i<=N-;++i)
if(!v[i])
for(int j=i*i;j<=N-;j+=i)
v[j]=;
for(int i=;i<=N-;++i)
if(!v[i])prime[++cnt]=i;
}
vector<int>g;
int main()
{
getprime();
int cas=,T;
scanf("%d",&T);
while(T--){
int t,n;
scanf("%d",&n),t=abs(n);
g.clear();
for(int i=;i<=cnt&&prime[i]<=t/prime[i];++i){
if(t%prime[i])continue;
int tot=;
while(t%prime[i]==)t/=prime[i],++tot;
g.push_back(tot);
}
if(t>)g.push_back();
int ans=;
if(n<){
for(int i=;i>;i-=){
bool flag=;
for(int j=;j<g.size();++j){
if(g[j]%i){
flag=;
break;
}
}
if(!flag){
ans=i;
break;
}
}
}
else{
for(int i=;i>;--i){
bool flag=;
for(int j=;j<g.size();++j){
if(g[j]%i){
flag=;
break;
}
}
if(!flag){
ans=i;
break;
}
}
}
printf("Case %d: %d\n",++cas,ans);
}
return ;
}

LightOJ 1220 Mysterious Bacteria 水题的更多相关文章

  1. LightOJ 1220 Mysterious Bacteria(唯一分解定理 + 素数筛选)

    http://lightoj.com/volume_showproblem.php?problem=1220 Mysterious Bacteria Time Limit:500MS     Memo ...

  2. LightOj 1220 - Mysterious Bacteria (分解质因子x=b^p 中的 x 求最大的 p)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1220 题意:已知 x=bp 中的 x 求最大的 p,其中 x b p 都为整数 x = ...

  3. LightOj 1220 Mysterious Bacteria

    题目大意: 给出一个x,求满足x = b^p,p最大是多少? 解题思路: x可以表示为:x = p1^e1 * p2^e2 * p3^e3 ....... * pn^en. p = gcd (e1,e ...

  4. LightOJ 1248 Dice (III) (水题,期望DP)

    题意:给出一个n面的色子,问看到每个面的投掷次数期望是多少. 析:这个题很水啊,就是他解释样例解释的太...我鄙视他,,,,, dp[i] 表示 已经看到 i 面的期望是多少,然后两种选择一种是看到新 ...

  5. codeforces Gym 100187H H. Mysterious Photos 水题

    H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...

  6. lightoj 1020 (博弈水题)

    lightoj 1020 A Childhood Game 链接:http://lightoj.com/volume_showproblem.php?problem=1020 题意:一堆石子有 m 个 ...

  7. LightOJ 1023 Discovering Permutations 水题

    http://www.lightoj.com/volume_showproblem.php?problem=1023 题意:26字母全排列 思路:用next_permutation或者思维想一下都可以 ...

  8. 二分--LIGHTOJ 1088查找区间(水题)

    #include <iostream> #include <cstdio> #include <cmath> using namespace std; const ...

  9. LightOJ 1214 Large Division 水题

    java有大数模板 import java.util.Scanner; import java.math.*; public class Main { public static void main( ...

随机推荐

  1. C++ const修饰函数、函数参数、函数返回值

    const修饰函数 在类中将成员函数修饰为const表明在该函数体内,不能修改对象的数据成员而且不能调用非const函数.为什么不能调用非const函数?因为非const函数可能修改数据成员,cons ...

  2. cookie、localStorage、sessionStorage之间的区别

    sessionStorage 和 localStorage 是HTML5 Web Storage API 提供的,可以方便的在web请求之间保存数据.有了本地数据,就可以避免数据在浏览器和服务器间不必 ...

  3. 实时监听input输入框value值的变化

    1.js 的 oninput & onpropertychange JS中的 oninput 事件在 IE9 以下版本不支持,需要使用 IE 特有的 onpropertychange 事件替代 ...

  4. 百度地图API应用实践(一) —— 栅格图(草稿)

    概述 运用百度地图JS API,实现了在百度地图上绘制栅格并按统计值渲染栅格颜色.实现的过程是不断补习的过程,其中用到一些技术,是个人首次尝试.包括:(1)简单的jQuery语法,并实现Ajax:(2 ...

  5. C#多线程(一)

    一.定义与理解 1.定义 线程是操作系统分配CPU时间片的基本单位,每个运行的引用程序为一个进程,这个进程可以包含一个或多个线程. 线程是进程中的执行流程,每个线程可以得到一小段程序的执行时间,在单核 ...

  6. 安装Android Studio报failed to find java version for 'C:\windows\system32\java.exe':[2] The system cannot find the specified file.错误的解决方案

    方案很简单,找到SYSTEM32目录下的java.exe文件,重命名为java.exe.orj. 方案出处:http://stackoverflow.com/questions/10339679/an ...

  7. leetcode解题—Longest Palindromic Substring

    题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum l ...

  8. hdu 1568 Fibonacci 数学公式

    Fibonacci Problem Description 2007年到来了.经过2006年一年的修炼,数学神童zouyu终于把0到的Fibonacci数列(f[0]=0,f[1]=1;f[i] = ...

  9. windows下STM32开发环境的搭建

    一.概述 1.说明 笔者已经写了一篇Linux下STM32开发环境的搭建 ,这两篇文章的最区别在于开发环境所处的系统平台不一样,而其实这个区别对于开发环境的搭建其实影响不大,制作局部上的操作上发生了改 ...

  10. MVC-Model数据注解(一)-系统(DataAnnotations)

    要使用验证,首先,web.config要开户验证: <appSettings> <add key="ClientValidationEnabled" value= ...