/*打表把素数能组合的数先设置成相应的位数*/
/* if n equals two and n is No.1 position of prime factors  so four position of prime factors is no.1,as well*/
/* although two can combined six but three also can combined six */
/* and three position of prime factors is two ,two covered one then six largest prime factor */
/*position is two now, have fun ;-) */

#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int *lpf = malloc( MAX*sizeof(int) ); /*if use "int lpf[MAX]" could be overflow*/
int n , num ;
int i , j ;
num = 0 ;
lpf[1] = 0 ;
for( i = 2 ; i < MAX ; i++ ) {
if( 0 == lpf[i] ){
num++ ;
for( j = i ; j < MAX ; j=j+i )
lpf[j] = num ;
} }
while( scanf("%d",&n) != EOF )
printf("%d\n",lpf[n]);
return 0;
}

【ACM】Largest prime factor的更多相关文章

  1. 【沙茶了+筛选保存最大质因数】【HDU2136】Largest prime factor

    Largest prime factor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  2. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

  3. The largest prime factor(最大质因数)

    1. 问题: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number ...

  4. HDOJ(HDU) 2136 Largest prime factor(素数筛选)

    Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...

  5. (Problem 3)Largest prime factor

    The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...

  6. 2136 Largest prime factor(打表)

    Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...

  7. Largest prime factor

    problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...

  8. Problem 3: Largest prime factor

    The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...

  9. R语言学习——欧拉计划(3)Largest prime factor 求最大质因数

    The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...

随机推荐

  1. Mongodb 3.4 Replication

    官方文档:https://docs.mongodb.com/manual/replication/ 关于ReplSet的文档 https://docs.mongodb.com/manual/refer ...

  2. 运行python程序不显示cmd的方法

    运行python程序的时候会在背景显示一个cmd,要想不显示其实很简单(虽然是我找了1个小时...才了解的基本知识) 方法1:pythonw xxx.py 方法2:将.py改成.pyw (这个其实就是 ...

  3. Python Unicode与中文处理(转)

    Python Unicode与中文处理 python中的unicode是让人很困惑.比较难以理解的问题,本文力求彻底解决这些问题: 1.unicode.gbk.gb2312.utf-8的关系: htt ...

  4. 记一次Python爬虫开发经历

    为啥要做Python爬虫,是因为我去找电影的某个网站有点坑,它支持tag标签查询自己喜欢的电影,但是不支持双标签或者三标签查询.由于一个电影对应多种类型(tag),这就意味着,我需要进入这个电影介绍界 ...

  5. Mysql远程连接报错:SQL Error (1130): Host '192.168.6.128' is not allowed to connect to this MySQL server

    通过SQLyog连接linux中的MySQL报错问题:SQL Error (1130): Host '192.168.6.128' is not allowed to connect to this ...

  6. 密码统计分析工具pipal

    密码统计分析工具pipal   pipal是Kali Linux提供的一款密码统计分析工具.该工具可以对一个密码字典的所有密码进行统计分析.它会统计最常用的密码.最常用的基础词语.密码长度占比.构成字 ...

  7. Compass用法

    一.什么是Compass? Compass是Sass的工具库,Compass在SASS的基础上,封装了一系列有用的模块去补充Sass的功能,类似Javascript和jQuery 二.安装 之前已经写 ...

  8. 【BZOJ 4572】【SCOI 2016】围棋

    http://www.lydsy.com/JudgeOnline/problem.php?id=4572 轮廓线DP:设\(f(i,j,S,x,y)\). \(S\)表示\((i,1)\)到\((i, ...

  9. qsc round#2 喵哈哈村的排队(本辣鸡想七想八的,特写此博文给自己一个提醒)

    该oj是qsc自己写的比赛,友情链接:http://qscoj.cn/ 喵哈哈村的排队 发布时间: 2017年2月26日 16:13   最后更新: 2017年2月26日 16:14   时间限制: ...

  10. AtCoder - 3939 Strange Nim

    Problem Statement Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles o ...