hdu Largest prime factor
类似于素数打表。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 1000100
using namespace std; int f[maxn]; void inti()
{
int num=;
for(int i=; i<maxn; i++)
{
if(f[i]==)
{
num++;
for(int j=i; j<maxn; j+=i)
{
f[j]=num;
}
}
}
} int main()
{
int n;
inti();
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",f[n]);
}
return ;
}
hdu Largest prime factor的更多相关文章
- 水题 第三站 HDU Largest prime factor
先写一遍思路,跟素数表很类似吧. 1)从小到大遍历数据范围内的所有数.把包含质因子的数的位置都设成跟质因子的位置相同. 2)同一个数的位置可能被多次复写.但是由于是从小到大遍历,这就保证了最后一次写入 ...
- 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 ...
- 2136 Largest prime factor(打表)
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...
- [暑假集训--数论]hdu2136 Largest prime factor
Everybody knows any number can be combined by the prime number. Now, your task is telling me what po ...
- 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 ...
- (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 ...
- 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 ...
随机推荐
- Raid1源代码分析--一些补充
Raid1的源码的读.写.同步,在本系列博客中都已经分析完成.除了barrier机制要专门拿出来分析(下一篇会写)以外,有一些问题值得思考和注意,分析如下. 1.freeze_array是如何做的? ...
- UVa400.Unix ls
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 深入理解linux网络技术内幕读书笔记(八)--设备注册与初始化
Table of Contents 1 设备注册之时 2 设备除名之时 3 分配net_device结构 4 NIC注册和除名架构 4.1 注册 4.2 除名 5 设备初始化 6 设备类型初始化: x ...
- 使用MapReduce将HDFS数据导入到HBase(二)
package com.bank.service; import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.conf. ...
- 无法找到脚本引擎Jscript解决
无法找到脚本引擎Jscript解决 CScript 错误: 无法找到脚本“InstallWizardForVS2010.js”的脚本引擎“JScript”. 目标环境:windows 7 64bit系 ...
- CSU1659: Graph Center(最短路)
Description The center of a graph is the set of all vertices of minimum eccentricity, that is, the s ...
- 四、Solr数据源配置(JNDI、DIH)及定时重做索引
简介 Solr支持很多种创建索引的方式,包括网页,xml以及数据库,因为我这边做的是企业级的搜索,所以用的是数据库建立索引.其实从数据库建立索引,很大程度上取决于原来的数据库设计. 从数据库建立索引, ...
- POJ 2502 Subway(迪杰斯特拉)
Subway Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6692 Accepted: 2177 Descriptio ...
- gcc总结【基本用法】【选项】【动静态库】(转)
1.////////////////////////////////////////////////////////////////////////////////////////////////// ...
- C#Transfrom
代码如下: private void btnConvertType_Click(object sender, EventArgs e) { if (rdo_btn_ConvertObject.Chec ...