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( ...
随机推荐
- JavaScript的语法要点 1 - Lexically Scoped Language
作为从一开始接触C.C++.C#的程序员而言,JavaScript的语法对我来说有些古怪,通过最近一年的接触,对它有了一定的了解,于是想把它的一些语法要点记录下来. 1. Block Scope vs ...
- django分页工具
from django.core.paginator import Paginator 此对象可以进行分页操作 objects = Entry.objects.all() page = Paginat ...
- PYTHON代码摘录
文件处理 #典型的读取文件代码 row_data = {} with open('PaceData.csv') as paces: column_heading = paces.readline(). ...
- CentOS添加RPMforge软件源
1.查看CentOS版本 cat /etc/redhat-release 2.查看系统位数 uname -i 3.下载rpm包 wget "rpm地址" CentOS 6: i68 ...
- Silverlight应用程序中调用WCF Ria Services访问数据库图片
WCF Ria Services(通常称为RIA服务),专门设计让Silverlight应用程序访问数据库,网上有关其示例应用都是基于简单的数据显示,其中MSDN网站上有详细的解决方案介绍,地址htt ...
- 数位DP入门之hdu 3555 Bomb
hdu 3555 Bomb 题意: 在1~N(1<=N<=2^63-1)范围内找出含有 ‘49’的数的个数: 与hdu 2089 不要62的区别:2089是找不不含 '4'和 '62'的区 ...
- ASP.NET MVC Razor视图(2)
昨天介绍了一些Razor的基本语法,几天接着向下说: 补成一个,上次介绍了怎么输出原样的文本,用<text></text>标签,下面再介绍一种语法: @{@:我爱北京} 这个 ...
- Git权威指南 读笔(4)
第12章 改变历史: $ git commit --amend -m "Remove hello.h, which is useless." 修改提交说明 $ git log -- ...
- Git权威指南 读笔(1)
第四章 Git初始化: 设置Git当前用户和邮件地址: $ git config --global user.name $ git config --global user.email 设置Git命令 ...
- sencha touch
download http://www.sencha.com/products/touch/thank-you/ Developer Center http://developer.sencha.co ...