HD-ACM算法专攻系列(18)——Largest prime factor
题目描述:

源码:
需要注意,若使用cin,cout输入输出,会超时。
#include"iostream"
#include"memory.h"
#define MAX 1000000
using namespace std; int index[MAX]; int main()
{ memset(index, -1, sizeof(index));
index[1] = 0;
int sum = 0;
for(int i = 2; i < MAX; i++)
{
if(index[i] == -1)
{
sum++;
for(int j = i; j < MAX; j+= i)
index[j]=sum;
}
} int n;
while(scanf("%d", &n) != EOF)
printf("%d\n", index[n]);
return 0;
}
HD-ACM算法专攻系列(18)——Largest prime factor的更多相关文章
- 【ACM】Largest prime factor
/*打表把素数能组合的数先设置成相应的位数*/ /* if n equals two and n is No.1 position of prime factors so four position ...
- 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 ...
- HDOJ(HDU) 2136 Largest prime factor(素数筛选)
Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...
- 【沙茶了+筛选保存最大质因数】【HDU2136】Largest prime factor
Largest prime factor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- (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 ...
- 2136 Largest prime factor(打表)
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...
- Largest prime factor
problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...
- 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 ...
- 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 ...
- [暑假集训--数论]hdu2136 Largest prime factor
Everybody knows any number can be combined by the prime number. Now, your task is telling me what po ...
随机推荐
- 2-SAT 小结
PS:今天(2014.10.27)准备PPT,明天在组合数学课上与大家一起分享一下2-SAT.我以为是一件简单的事情.但是,当我看了自己这篇博客以后,发现居然还是不懂.很多资料不全,也没仔细讲.整理了 ...
- VS2012编译PCL1.70的过程
以防博主删除文档,重新copy一遍... 关于个人的几个注意事项: 对于boost,可以使用vc100的库,来编译VC110的代码: 对于确实的包含,一个一个添加,要耐心等待!!! 原文链接:http ...
- vue项目中引用echarts的几种方式
准备工作: 首先我们初始化一个vue项目,执行vue init webpack echart,接着我们进入初始化的项目下.安装echarts, npm install echarts -S //或 ...
- ArcGIS Javascript API 加载高德在线地图扩展
利用ArcGIS JavaScript API加载高德在线地图的扩展 /** * Created by WanderGIS on 2015/7/15. */ define(["dojo/_b ...
- swift类型操作规范
type(of:) Applied to an object: the polymorphic (internal) type of the object, regardless of how a r ...
- python的jieba分词
# 官方例程 # encoding=utf-8 import jieba seg_list = jieba.cut("我来到北京清华大学", cut_all=True) print ...
- 使用ant design pro搭建项目
脚手架搭建 git clone --depth=1 https://github.com/ant-design/ant-design-pro.git my-project 然后 cd my-proje ...
- [tyvj2054] 四叶草魔杖 (最小生成树 状压dp)
传送门 Background 陶醉在彩虹光芒笼罩的美景之中,探险队员们不知不觉已经穿过了七色虹,到达了目的地,面前出现了一座城堡和小溪田园,城堡前的木牌上写着"Poetic Island&q ...
- Python 绘制2016世界GDP地图
2016世界GDP地图 从https://datahub.io/core/gdp#data下载得到json文件. # country_code.py 获取国家二字代码 # 从pygal.maps.wo ...
- base64格式文件下载方法
下载图片时,接口返回的地址是base64格式的文件数据,因为页面需要把base64格式的数据转换为文件,再进行下载: 解决方案: 下载按钮: <el-button type="defa ...