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的更多相关文章
随机推荐
- java中protect属性用法总结
测试代码: pojo类: package com.lky.h1; public class Base { private Integer id; protected String name; publ ...
- CentOS 设置mysql的远程访问
好记性不如烂笔头,记录一下. 安装了MySQL默认是拒绝远程连接的. 首先进入数据库,使用系统数据库mysql. mysql -u root -p mysql #回车,然后输入则使用了系统数据库 接着 ...
- less.css基础学习,陆续更新中
//基础//概念:动态样式语言,有很多语言的特性:变量,函数,运算等 //变量:通过一个简单的@+字母,数字下划线等,但不能以数字开头,不能关键字,保留字等//注意less.css是全局变量,除在函数 ...
- Chrome真机调试步骤
确保手机端打开USB调试选项 手机安装chrome 手机访问网页(或者打开APP,或者使用夜深模拟器打开APP或者网页) PC chrome打开chrome://inspect/#devices 点击 ...
- Lesson2.1:LinkedList、ConcurrentLinkedQueue、LinkedBlockingQueue对比分析
写这篇文章源于我经历过的一次生产事故,在某家公司的时候,有个服务会收集业务系统的日志,此服务的开发人员在给业务系统的sdk中就因为使用了LinkedList,又没有做并发控制,就造成了此服务经常不能正 ...
- [Angular 2] @ViewChild to access Child component's method
When you want to access child component's method, you can use @ViewChild in the parent: Parent Compo ...
- PropertyGird( 属性表格) 组件
本节课重点了解 EasyUI 中 PropertyGird(属性表格)组件的使用方法,这个组件依赖于 DataGrid(数据表格)组件. 一. 加载方式 //class 加载方式<table i ...
- tomcat 远程 调试 eclipse
windows系统: 修改catalina.bat 端口9000 SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE ...
- Ganglia 监控Hadoop
Ganglia监控Hadoop集群的安装部署 一. 安装环境 Ubuntu server 12.04 安装gmetad的机器:192.168.52.105 安装gmond的机 器:192.168.52 ...
- Swift中的便利构造器和构造器链
import UIKit // 1.一个类中至少有一个指定构造器, 其必须负责初始化类中所有的实例存储属性 // 2.便利构造器属于次要的, 辅助性的构造器 // 3.类中可以不定义便利构造器, 便利 ...