[暑假集训--数论]hdu2136 Largest prime factor
2024-09-01 22:19:06
Everybody knows any number can be combined by the prime number.
Now, your task is telling me what position of the largest prime factor.
The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc.
Specially, LPF(1) = 0.
Now, your task is telling me what position of the largest prime factor.
The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc.
Specially, LPF(1) = 0.
InputEach line will contain one integer n(0 < n < 1000000).
OutputOutput the LPF(n).
Sample Input
1
2
3
4
5
Sample Output
0
1
2
1
3
对x分解质因数,问最大的质因子是第几大质数
瞎暴力就好
#include<cstdio>
#include<algorithm>
#define LL long long
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int mk[];
int pp[],len;
int rnk[];
int n;
inline void getp()
{
for (int i=;i<=;i++)
{
if (!mk[i])
{
for (int j=*i;j<=;j+=i)mk[j]=;
pp[++len]=i;
rnk[i]=len;
}
}
}
int main()
{
getp();
while (~scanf("%d",&n))
{
if (!mk[n]){printf("%d\n",rnk[n]);continue;}
int mx=;
for (int i=;i<=len;i++)
{
if (pp[i]*pp[i]>n)break;
if (n%pp[i]==)mx=i;
while (n%pp[i]==)n/=pp[i];
}
if (n!=)mx=rnk[n];
printf("%d\n",mx);
}
}
hdu 2136
最新文章
- UVa 1648 (推公式) Business Center
- linux实现nginx按照日期存储日志
- MySQL之事务处理、存储过程
- git 在苹果系统中的一些命令
- Robot Framework: 自定义自己的python库
- ubuntu14.04中virtualbox虚拟机无法启动
- 【Zookeeper】源码分析之Watcher机制(二)
- C++开发基础
- mysql中截取指定字符前后的字符串
- Android 内存溢出解决方案(OOM) 整理总结<;转>;
- 怎么去掉Xcodeproject中的某种类型的警告 Implicit conversion loses integer precision: &;#39;NSInteger&;#39; (aka &;#39;long&;#39;) to &;#39;int32
- 深度学习 + OpenCV,Python实现实时视频目标检测
- SoapUI&#160;接口测试之post提交本地数据文件
- # 20155337《网络对抗》Exp9 Web安全基础
- keras load model 遇到 自定义函数 Lambda(lambda x: softmax(x, axis=1), NameError: global name &#39;softmax&#39; is not defined
- ZH奶酪:【Python】random模块
- ZOJ 3541 The Last Puzzle(经典区间dp)
- 服务器jupyter配置与ssh远程登录
- asp.net web 应用站点支持域账户登录
- jquery中国地图插件
热门文章
- HttpServletRequest HttpServletResponse ServletException 重新打开后报红解决方法
- Log错误日志级别
- form中 单选框 input[type="radio"] 分组
- TP5数据库操作方法总结
- Python Map, Filter and Reduce
- oracle insert用法总结
- systick运用
- 刷表法动态规划:HOJ11391_Word Clouds Revisited
- Analyze Program Runtime Stack
- 平衡树 - Luogu 1486 郁闷的出纳员