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. 

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

最新文章

  1. UVa 1648 (推公式) Business Center
  2. linux实现nginx按照日期存储日志
  3. MySQL之事务处理、存储过程
  4. git 在苹果系统中的一些命令
  5. Robot Framework: 自定义自己的python库
  6. ubuntu14.04中virtualbox虚拟机无法启动
  7. 【Zookeeper】源码分析之Watcher机制(二)
  8. C++开发基础
  9. mysql中截取指定字符前后的字符串
  10. Android 内存溢出解决方案(OOM) 整理总结&lt;转&gt;
  11. 怎么去掉Xcodeproject中的某种类型的警告 Implicit conversion loses integer precision: &amp;#39;NSInteger&amp;#39; (aka &amp;#39;long&amp;#39;) to &amp;#39;int32
  12. 深度学习 + OpenCV,Python实现实时视频目标检测
  13. SoapUI&#160;接口测试之post提交本地数据文件
  14. # 20155337《网络对抗》Exp9 Web安全基础
  15. keras load model 遇到 自定义函数 Lambda(lambda x: softmax(x, axis=1), NameError: global name &#39;softmax&#39; is not defined
  16. ZH奶酪:【Python】random模块
  17. ZOJ 3541 The Last Puzzle(经典区间dp)
  18. 服务器jupyter配置与ssh远程登录
  19. asp.net web 应用站点支持域账户登录
  20. jquery中国地图插件

热门文章

  1. HttpServletRequest HttpServletResponse ServletException 重新打开后报红解决方法
  2. Log错误日志级别
  3. form中 单选框 input[type="radio"] 分组
  4. TP5数据库操作方法总结
  5. Python Map, Filter and Reduce
  6. oracle insert用法总结
  7. systick运用
  8. 刷表法动态规划:HOJ11391_Word Clouds Revisited
  9. Analyze Program Runtime Stack
  10. 平衡树 - Luogu 1486 郁闷的出纳员