HDOJ 2136 Largest prime factor
2016-01-20 19:34
232 查看
Largest prime factor
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9250 Accepted Submission(s): 3268
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
Each line will contain one integer n(0 < n < 1000000).
[align=left]Output[/align]
Output the LPF(n).
[align=left]Sample Input[/align]
1 2 3 4 5
[align=left]Sample Output[/align]
0 1 2 1 3
[align=left]Author[/align]
Wiskey
[align=left]Source[/align]
HDU 2007-11 Programming Contest_WarmUp
[align=left]Recommend[/align]
威士忌 | We have carefully selected several similar problems for you: 2138 2133 2135 1215 2137
很有意思的一道题,更加理解素数打表原理。
前两天做的好像没传上来,今天扔上来。
#include<stdio.h> #include<string.h> #define Max 1000001 int a[Max]; void S() { int i,j; int k=1; memset(a,0,sizeof(a)); for(i=2;i<Max;i++) { if(!a[i]) a[i]=k++; for(j=i+i;j<Max;j+=i) a[j]=a[i]; } } int main() { S(); int n; while(~scanf("%d",&n)) printf("%d\n",a ); return 0; }
相关文章推荐
- 设计模式——装饰者模式 Java源代码
- sed命令用法详解
- 递归与尾递归
- MyBatis批量插入数据
- C++:重载函数2(计算面积)
- U8SDK——Cocos2dx游戏快速渠道SDK接入
- 使用autoCompleteTextView以及MultiAutoCompleteTextView实现自动匹配输入内容
- linux grep命令详解
- Quartz2.2.1开发问题
- Quartz2.2.1开发问题
- 修改apache服务器根目录
- 关于NSCache的使用
- Netty使用Marshalling传输信息
- springMVC 接收数组参数,mybatis 接收数组参数,mybatis批量插入/批量删除案例
- Synchronized
- 深度学习框架Caffe的编译安装
- 《魔兽世界》的魅力究竟在哪儿?
- mysql + SpringMVC + MyBatis中批量插入实例以及@Param注解的用法
- LeetCode Edit Distance
- APUE读书笔记