题目描述:

源码:

需要注意,若使用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的更多相关文章

  1. 【ACM】Largest prime factor

    /*打表把素数能组合的数先设置成相应的位数*/ /* if n equals two and n is No.1 position of prime factors  so four position ...

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

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

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

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

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

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

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

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

随机推荐

  1. angular实现的tab栏切换

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 【Oracle】ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

    出现此错误的原因是因为事务等待造成的,找出等待的事务,kill即可. 下面是我当时遇到的错误: ---删除表t1时出现错误 SCOTT@GOOD> drop table t1; drop tab ...

  3. 【Oracle】RMAN备份

    1. 完全备份 RMAN> backup as backupset database; Starting allocated channel: ORA_DISK_1 channel ORA_DI ...

  4. 计算机二级考试Access教程

    本教程对编程语言各种要点进行详细的讲解介绍,从基础知识到实用技术功能,内容涵盖了从数组,类等基本概念到多态.模板等高级概念.教程本着实用的原则,每一小节都结合了可以笔试.面试的常见程序实例,以便从第一 ...

  5. ES5:深入解析如何js定义类或对象。

    1.原始方式 var oCar = new  Object; oCar.color = "blue"; oCar.showColor = function(){alert(this ...

  6. phpstudy不显示目录列表---设置方法

    打开phpstudy,显示的项目文件路径不见了,其实是phpstudy的设置问题.以下是设置方法. 并将一下几个文件删除即可

  7. 检索源码 删除无用Properties的小工具

    背景: 重新做项目的过程中,引用了大量旧代码.尤其是Properties文件,里面肯定有一批是无用的,干脆笨办法直接扫描源码文件来过滤. 后续在此基础上修改修改,再做个扫描无用image文件的类. 代 ...

  8. 在maven项目结构下对于Resources目录下文件的存取

    在maven项目中,文件结构如下: proj ---src ----main ----java ----Main.java ----resources ----userFile.properties ...

  9. 给 iOS 开发者的 RxSwift(一)

    RxSwift 或许我们都听说过,但或许只知道 RxSwift 这个单词,长篇大论关于 RxSwift 的介绍往往使读者迷失在各种概念当中,却不知如何让它大展伸手.或许我们可以换一种姿势,一些应用场景 ...

  10. 利用chrome浏览器断电调试确定函数触发的位置

    比如某天遇到这样一个问题,页面有一个按钮,上面绑定了事件可能是多个事件,然后我们点击后出现了bug,我们要如何快速定位到这个事件,如果页面只有一个js或少量的js,我们一个打开查找,也可以接受.但是如 ...