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

[暑假集训--数论]hdu2136 Largest prime factor的更多相关文章

  1. 数学--数论--HDU2136 Largest prime factor 线性筛法变形

    Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...

  2. [HDU2136] Largest prime factor(素数筛)

    传送门 题意 给出若干个数n(n<=1000000),求每个n的最大质因子的排名. 质数的排名:如果素数p是第k小的素数,那么p的排名就是k. 思路 乍一看不知道怎么搞. 其实可以想想我们怎么筛 ...

  3. 【沙茶了+筛选保存最大质因数】【HDU2136】Largest prime factor

    Largest prime factor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  4. The largest prime factor(最大质因数)

    1. 问题: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number ...

  5. HDOJ(HDU) 2136 Largest prime factor(素数筛选)

    Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...

  6. (Problem 3)Largest prime factor

    The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...

  7. 2136 Largest prime factor(打表)

    Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...

  8. Largest prime factor

    problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...

  9. Problem 3: Largest prime factor

    The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...

随机推荐

  1. 逗塔战争TD新人入门图文攻略

    逗塔战争TD新人入门图文攻略   <逗塔战争TD>是一张基于DOTA改编的塔防TD,很多玩家都很喜欢这张图,新手玩家怎么快速上手这张图呢?这张图的玩法和基本规则并不难,下面就为大家带来新人 ...

  2. 微服务SpringCloud+Docker入门到高级实战(教程详情)

    第一章 课程介绍和学习路线 1.微服务架构SpringCloud课程介绍 简介:课程介绍和课程大纲讲解,讲课风格和重点内容理解技巧 2.技术选型和学后水平 简介:课程所需基础和技术选型讲解,学完课程可 ...

  3. 1047: [HAOI2007]理想的正方形

    Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4075  Solved: 2277[Submit][Status][Discuss] Descript ...

  4. Uva 网络(Network,Seoul 2007,LA 3902)

    #include<iostream> #include<cstring> #include<vector> using namespace std; +; int ...

  5. Duizi and Shunzi HDU - 6188 (贪心)2017 广西ACM/ICPC

    Duizi and Shunzi Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. 笔记1 python入门学习笔记

    目录 官方手册 菜鸟站手册地址: python的运行方法 注释 小技巧: input()接收用户输入的内容(默认为字符串) print() 运算符 is 是判断两个标识符是不是引用自一个对象 all和 ...

  7. [原]sencha touch之carousel

    carousel组件是个非常不错的东东,自带可滑动的效果,效果如下图 上面部分可以左右滑动,下面部分可以上下滑动,效果还是不错的,app程序中很有用的布局 代码如下: Ext.application( ...

  8. Android stadio 电脑连上手机可以识别,但是连不上Android stadio

    原来是因为电脑没有装Android 手机驱动,我电脑刚装了系统. 很多驱动没有装.我有一个联想驱动管理,提示我装Android手机驱动.装完之后,就可以识别到手机了. 如果你的手机在电脑不识别,那么装 ...

  9. Logistic回归python实现小样例

    假设现在有一些点,我们用一条直线对这些点进行拟合(该线称为最佳拟合直线),这个拟合过程就称作回归.利用Logistic回归进行分类的主要思想是:根据现有数据对分类边界线建立回归公式,依次进行分类.Lo ...

  10. package.json文件特殊符号含义

    package.json文件里的^和~表示什么意思呢 In the simplest terms, the tilde matches the most recent minor version (t ...