HDU 2136 Largest prime factor
来源:互联网 发布:淘宝挂拍摆衣服技巧 编辑:程序博客网 时间:2024/06/18 14:15
http://acm.hdu.edu.cn/showproblem.php?pid=2136
Largest prime factor
Time Limit: 5000/1000 MS(Java/Others)
Total Submission(s):2815
Problem Description
Everybody knows any number can becombined by the prime number.
Now, your task is telling me what position of the largest primefactor.
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 primefactor.
The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3,etc.
Specially, LPF(1) = 0.
Input
Each line will contain one integer n(0< n < 1000000).
Output
Output the LPF(n).
Sample Input
1 2 3 45
Sample Output
0 1 2 13
Author
Wiskey
Source
HDU 2007-11 Programming Contest_WarmUp
Recommend
威士忌
题意:给一个数,求它的最大质因子在素数中的排名。1为0,2为1,3为2……
分析:用哈希打表的方法搞定
代码如下:
#include<stdio.h>
#include<string.h>
int biao[1000001];
void fun()
{
int i,j,k=1;
memset(biao,0,sizeof(biao));
for(i=2;i<1000000;i++)
{
if(biao[i]==0)
{
for(j=1;i*j<999999;j++)
biao[i*j]=k;
k++;
}
}
biao[1]=0;
}
int main()
{
int n;
fun();
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",biao[n]);
}
return 0;
}
#include<string.h>
int biao[1000001];
void fun()
{
}
int main()
{
}
阅读全文
0 0
- HDU 2136 Largest prime factor
- Largest prime factor
- HDU 2710 Max Factor
- HDU How many prime numbers
- hdu 1016 Prime Ring Problem
- HDU 1242 Rescue
-  
- Nth Largest Value
- poj 3126 Prime Path
- poj 3126 Prime Path
-
- usaco Prime Cryptarithm
- HDOJ 1016 Prime Ring Problem
- ZZULI_SummerPractice(3) HDU 1…
- HDU 1579 Function Run Fun
- HDU 1405 The Last Practice
- HDU 2050 折线分割平面
- hdu 1000 A + B Problem
- Androidstudio开发ARcore
- codeforces Balanced Substring
- HDU 2153 仙人球的残影
- HDU 2137 circumgyrate the string
- DES算法设计
- HDU 2136 Largest prime factor
- jenkin迁移恢复
- HDU 2135 Rolling table
- HDU 2131 Probability
- 行人属性--HydraPlus-Net: Attentive Deep Features for Pedestrian Analysis
- 作为QA角色去产品部门,想要了解某个产品部门的研发情况,应该从哪几个方面入手?
- SQL语句的学习(初)
- HDU 2115 I Love This Game
- HDU 2109 Fighting for HDU