类似于素数打表。

 #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的更多相关文章

  1. 水题 第三站 HDU Largest prime factor

    先写一遍思路,跟素数表很类似吧. 1)从小到大遍历数据范围内的所有数.把包含质因子的数的位置都设成跟质因子的位置相同. 2)同一个数的位置可能被多次复写.但是由于是从小到大遍历,这就保证了最后一次写入 ...

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

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

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

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

  4. 2136 Largest prime factor(打表)

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

  5. [暑假集训--数论]hdu2136 Largest prime factor

    Everybody knows any number can be combined by the prime number. Now, your task is telling me what po ...

  6. 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 ...

  7. (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 ...

  8. Largest prime factor

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

  9. 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 ...

随机推荐

  1. 总结:man, info, hwclock, cal, type, which, dirname, basename, who, which, whatis, makewhatis, hash, tty

    man, info, help, date, hwclock, cal, shutdown, reboot, halt, poweroff, type, cd, which, dirname, bas ...

  2. hdu4324 拓扑排序

    #include<cstdio> #include<string.h> #define maxn 2013 char M[maxn][maxn]; int du[maxn]={ ...

  3. 数据库中的schema概念

    原文地址:http://blog.sina.com.cn/s/blog_7952e89001010jlj.html 数据库的初学者往往会对关系型数据库模式(schema).数据库(database). ...

  4. nginx本地的测试环境添加SSL

    要在本地添加SSL,首先要做的是防火墙是不是放开了443端口,同时,在nginx安装时是不是支持了ssl模块,这个安装网上很容易找到相关资料 防火墙,个人还是用iptables比较直观 先将selin ...

  5. solr全文检索基本原理

    场景:小时候我们都使用过新华字典,妈妈叫你翻开第38页,找到“坑爹”所在的位置,此时你会怎么查呢?毫无疑问,你的眼睛会从38页的第一个字开始从头至尾地扫描,直到找到“坑爹”二字为止.这种搜索方法叫做顺 ...

  6. (转)重置Mac OS X管理员密码

    忘记Mac管理员密码怎么办?别担心,办法总会有的. [方法一] 开机按住option,选择Recovery HD(Snow Leopard插入光盘开机按住C) Snow Leopard系统:进入后在上 ...

  7. i++与++i的区别,使用实例说明

    /** * 类名:TEST.java<br> * <p> * 功能:i++与++i的区别,使用实例说明 * </p> * * @Author:<a href= ...

  8. 正则表达式JSP实例

    <%@ page language="java" import="java.util.*,cn.com.Person,cn.com.Adddress" p ...

  9. Linux系统 fdisk命令 创建新分区

    --fdisk命令fdisk -l /dev/sda           # 查看分区 fdisk    /dev/sda           # 创建分区  n                    ...

  10. linux命令之seq

    seq命令简述 seq命令比较常用,在需要做循环的时候用于产生一个序列是再合适不过的工具了,常用方法也比较简单: Usage:      seq [OPTION]... LAST      seq [ ...