ACM2136
- /*
- Problem Description
- 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.
- Input
- Each line will contain one integer n(0 < n < 1000000).
- Output
- Output the LPF(n).
- Sample Input
- 1
- 2
- 3
- 4
- 5
- Sample Output
- 0
- 1
- 2
- 1
- 3
- */
- #include <stdio.h>
- #include <string.h>
- const int N = ;
- int hash[N+];
- int prime[N+];
- void sushu()
- {
- int i,j;
- memset(prime,,sizeof(prime));
- hash[] = ;
- int flag = ;
- for(i = ; i<=N; i++)
- {
- if(!prime[i])
- {
- hash[i] = ++flag;
- for(j = i; j<=N; j+=i)
- {
- prime[j] = i;
- }
- }
- }
- }
- int main()
- {
- int i;
- memset(hash,,sizeof(hash));
- sushu();
- while(~scanf("%d",&i))
- {
- if(i == )
- printf("0\n");
- else
- {
- int k = prime[i];
- printf("%d\n",hash[k]);
- }
- }
- return ;
- }
ACM2136的更多相关文章
随机推荐
- DS18B20
DS18B20驱动 [ 2012-5-14 12:01:00 | By: 吴师傅 ] 14 推荐 一.概述 DS18B20是一种单总线数字温度传感器.測试温度范围-55℃-125℃,温度数据位可配 ...
- openflow tutorial 开始openflow的学习(一)
首先不废话介绍openflow了,自己也还搞不清楚究竟是个什么玩意儿,概括不出什么内容来,先做试验,有个大体的感性了解回来再总结吧. 第一步,搭建环境,这一步就是安装工具,不同的系统环境搭建不一致,我 ...
- JavaScript的68个技巧一
1. 严格模式 在自己的项目中 你可以坚持只使用" 严格模式 " 或只使用" 非严格模式 "的策略.但如果你要编写健壮的代码应对各种各样的代码连接 你有两个可选 ...
- linux-Python升级安装
Wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz tar zxvf Python-3.5.0.tar.gz && ...
- 你的sscanf用对了吗
用sscanf解析输入字符串 我们平常编写的很多应用程序都会处理各种各样的输入,这些输入或来自本地文件,或来自网络,或来自用户的输入.今天,让我们来看看sscanf这个和字符串相关的函数可能给你带来的 ...
- java基础之导入(药师点评)
/** * 药师点评的导入 * @param request * @param response * @param f * @param tmallTcMessageImport * @return ...
- Java初转型-Maven入门
原系列名:Maven学习总结(一) 原博文出自于:http://www.cnblogs.com/xdp-gacl/p/3498271.html 感谢! 一.Maven的基本概念 Maven(翻译为&q ...
- TimeSpinner( 时间微调) 组件
本节课重点了解 EasyUI 中 Spinner(微调)组件的使用方法,这个组件依赖于Spinner(微调)组件. 一. 加载方式//class 加载方式<input id="box& ...
- 3.Android Studio系列教程3——快捷键
原文链接:http://stormzhang.com/devtools/2014/12/09/android-studio-tutorial3/ 一.更新Android Studio 项目根目录的 ...
- RecycleView 瀑布流滑动移位
RecycleView StaggeredLayoutManager(瀑布流)滑动的时候,默认会出现item移动的问题,需以下来个步骤来解决: 附上StaggeredLayoutManager中的一段 ...