LightOJ 1220 Mysterious Bacteria 水题
暴力就行了,找出素因子,正的最多是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 水题的更多相关文章
- LightOJ 1220 Mysterious Bacteria(唯一分解定理 + 素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1220 Mysterious Bacteria Time Limit:500MS Memo ...
- 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 = ...
- LightOj 1220 Mysterious Bacteria
题目大意: 给出一个x,求满足x = b^p,p最大是多少? 解题思路: x可以表示为:x = p1^e1 * p2^e2 * p3^e3 ....... * pn^en. p = gcd (e1,e ...
- LightOJ 1248 Dice (III) (水题,期望DP)
题意:给出一个n面的色子,问看到每个面的投掷次数期望是多少. 析:这个题很水啊,就是他解释样例解释的太...我鄙视他,,,,, dp[i] 表示 已经看到 i 面的期望是多少,然后两种选择一种是看到新 ...
- codeforces Gym 100187H H. Mysterious Photos 水题
H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- lightoj 1020 (博弈水题)
lightoj 1020 A Childhood Game 链接:http://lightoj.com/volume_showproblem.php?problem=1020 题意:一堆石子有 m 个 ...
- LightOJ 1023 Discovering Permutations 水题
http://www.lightoj.com/volume_showproblem.php?problem=1023 题意:26字母全排列 思路:用next_permutation或者思维想一下都可以 ...
- 二分--LIGHTOJ 1088查找区间(水题)
#include <iostream> #include <cstdio> #include <cmath> using namespace std; const ...
- LightOJ 1214 Large Division 水题
java有大数模板 import java.util.Scanner; import java.math.*; public class Main { public static void main( ...
随机推荐
- spl_autoload_register array参数
spl_autoload_register (PHP 5 >= 5.1.2) spl_autoload_register — 注册给定的函数作为 __autoload 的实现 说明¶ bool ...
- selenium自动化测试(1):环境搭建
Selenium是一款优秀的WEB自动化测试工具,它功能强大,易于使用,支持多种平台.多种浏览器和多种开发语言.这里介绍使用python+selenium进行自动化测试的一些基础知识. 在Window ...
- Python3 IO
在磁盘上读写文件的功能都是由操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘,所以,读写文件就是请求操作系统打开一个文件对象(通常称为文件描述符),然后,通过操作系统提供的接口从这个文件对象中 ...
- JS判断输入框值是否为空
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- LBS地理位置距离计算方法之geohash算法
随着移动终端的普及,很多应用都基于LBS功能,附近的某某(餐馆.银行.妹纸等等).基础数据中,一般保存了目标位置的经纬度:利用用户提供的经纬度,进行对比,从而获得是否在附近.这里需要在设置出一个字段, ...
- FolderBrowserDialog(文件夹浏览对话框)
1.选择数据库目录,在此处不需要新建文件夹,因此屏蔽新建文件夹按钮. C#代码 FolderBrowserDialog df = new FolderBrowserDialog(); //设置文件浏览 ...
- Sublime Text 2 插件
一直以来写代码都是用的EditPlus,也尝试了一段时间学习Vim这神器,后来因为使用不习惯还是改回了原来的EditPlus.前几天朋友想我推荐了Sublime Text 2,喜欢尝鲜我的肯定是不会放 ...
- awk的使用备忘
[转]http://www.cnblogs.com/mydomain/archive/2012/09/24/2699467.html awk引用外部变量 一.用awk 有以下几种方法去调用变量: ...
- css中table-layout:fixed 属性的用法
table-layout:fixed 属性的用法:如果想要一个table固定大小,里面的文字强制换行(尤其是在一长串英文文本,并且中间无空格分隔的情况下),以达到使过长的文字 不撑破表格的目的,一般是 ...
- 基于android混合开发的JsBridge技术学习
1.无JsBridge. js如果要调用java(native.也说原生)方法:则java必须实现js接口供挂载在window对象上供js来执行. 这里简单的可以只调用,调用后java端什么也不做.复 ...