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的更多相关文章
随机推荐
- (转)How to renew your Apple Push Notification Push SSL Certificate
转自:https://blog.serverdensity.com/how-to-renew-your-apple-push-notification-push-ssl-certificate/ It ...
- pptv web前端面试题答案
这是星期一考完试,答应星期三补上的,代码很简单,就不写注释了 //php快排 function quickSort(&$arr){ $arr_left=new array(); $ar ...
- openwrt上网配置的一些理解(四)
这次要解决的问题是3g上网和wan口上往可以随意切换,当然能够叠加也是好事,不过这不是我关心的.下面还是修改3个文件network,firewall,multiwan.首先在network中加入界面配 ...
- [Typescript] Typescript Enums vs Booleans when Handling State
Handling state with Typescript enums, instead of booleans, is preferred because:- Enums are more rea ...
- Codeforces 328A-IQ Test(数列)
A. IQ Test time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Gcc简介与常用命令
一.对于GUN编译器来说,程序的编译要经历预处理.编译.汇编.连接四个阶段,如下图所示: 在预处理阶段,输入的是C语言的源文件,通常为*.c.它们通常带有.h之类头文件的包含文件.这个阶段主要处理源文 ...
- (一)MVP设计模式
一.MVP介绍 随着UI创建技术的功能日益增强,UI层也履行着越来越多的职责.为了更好地细分视图(View)与模型(Model)的功能,让View专注于处理数据的可视化以及与用户的交互,同时 ...
- Shell防DDOS攻击原理
#!/bin/sh #date:2015-12-13 #filename:fang-DOS.sh #version:v1.0 while true do #awk '{print $1}' ...
- R语言编程艺术# 矩阵(matrix)和数组(array)
矩阵(matrix)是一种特殊的向量,包含两个附加的属性:行数和列数.所以矩阵也是和向量一样,有模式(数据类型)的概念.(但反过来,向量却不能看作是只有一列或一行的矩阵. 数组(array)是R里更一 ...
- 【VS2015正式版下载】Visual Studio 2015 正式版开放下载 Visual Studio 2015 神key
说明: 微软定于2015年7月20日发布Visual Studio 2015正式版,目前其官方网站已经提供正式版本的下载. 可在https://www.visualstudio.com/en-us/d ...