The first two consecutive numbers to have two distinct prime factors are:

14 = 2 × 7

15 = 3 × 5

The first three consecutive numbers to have three distinct prime factors are:

644 = 2² × 7 × 23

645 = 3 × 5 × 43

646 = 2 × 17 × 19.

Find the first four consecutive integers to have four distinct prime factors. What is the first of these numbers?

#include <iostream>
#include <map>
using namespace std; int factors(int n)
{
map<int, int>mp;
int i = 2;
while (n > 1)
{
if (n%i == 0)
{
mp[i]++;
n /= i;
}
else
i++;
}
return mp.size();
} int main()
{
for (int i = 20; i <= 1000000; i++)
{
if (factors(i) == 4)
{
if (factors(i + 1) == 4)
{
if (factors(i + 2) == 4)
{
if (factors(i + 3) == 4)
{
cout << i << endl;
break;
}
}
}
}
}
system("pause");
return 0;
}

Project Euler:Problem 47 Distinct primes factors的更多相关文章

  1. Project Euler:Problem 58 Spiral primes

    Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length ...

  2. Project Euler:Problem 37 Truncatable primes

    The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...

  3. Project Euler 47 Distinct primes factors( 筛法记录不同素因子个数 )

    题意: 首次出现连续两个数均有两个不同的质因数是在: 14 = 2 × 715 = 3 × 5 首次出现连续三个数均有三个不同的质因数是在: 644 = 22 × 7 × 23645 = 3 × 5 ...

  4. Project Euler:Problem 55 Lychrel numbers

    If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindr ...

  5. Project Euler:Problem 86 Cuboid route

    A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and a fly, F, sits in the o ...

  6. Project Euler:Problem 87 Prime power triples

    The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is ...

  7. Project Euler:Problem 93 Arithmetic expressions

    By using each of the digits from the set, {1, 2, 3, 4}, exactly once, and making use of the four ari ...

  8. Project Euler:Problem 63 Powerful digit counts

    The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is ...

  9. Project Euler:Problem 76 Counting summations

    It is possible to write five as a sum in exactly six different ways: 4 + 1 3 + 2 3 + 1 + 1 2 + 2 + 1 ...

随机推荐

  1. ORACLE导入导出操作篇

    1. DIRECTORY 指定转储文件和日志文件所在的目录DIRECTORY=directory_objectDirectory_object用于指定目录对象名称.需要注意,目录对象是使用CREATE ...

  2. 开源的Android开发框架-------PowerFramework使用心得(二)图片异步加载ImageTask

    图片异步加载.可以备注图片是否缓存.缓存状态. 1.缓存-SD卡,路径可设置 2.图片压缩 3.可加载本地和网络图片 4.url为本地视频文件可以显示缩略图 5.中文url图片地址FileNotFou ...

  3. 阿里云OSS存储开发(一)

    Step 1. 初始化一个OSSClient OSSClient是与OSS服务交互的客户端,SDK的OSS操作都是通过OSSClient完成的. 下面代码新建了一个OSSClient: using A ...

  4. [转] 关于UIView

    [转载] 原文地址 :http://blog.csdn.net/itianyi/article/details/8982518 UIView是开发中使用得最多的控件了,深入的理解很有必要. UIVie ...

  5. js apply

    1.作用 函数的apply方法的作用与call方法类似,也是改变this指向,然后再调用该函数.唯一的区别就是,它接收一个数组作为函数执行时的参数 Fn.apply(obj, [arg1, arg2, ...

  6. interrupt & storage & DMA

    1.Interrupt: The occurrence of an event is usually signaled by aninterrupt from either the hardware ...

  7. Java获取昨天的时间

    Calendar   cal   =   Calendar.getInstance();  cal.add(Calendar.DATE,   -1);  String yesterday = new ...

  8. javascript权威指南学习笔记1

    打开这本书,进入到javascript的世界.以前都是看各种视频,感觉什么收获也没有,反而弄得脑袋混乱,希望能够按照这本书的节奏掌握javascript这门语言,为我的前端学习打下基础. 学习前准备: ...

  9. jquery ajax用例样板

    $.ajax({ url: '${managerPath}/customer/updateOrder.do', type: 'POST', async: false, data: { id: date ...

  10. 替代 yunio , 推荐一个国外的云存储(同步盘) wuala(这个网站也挂了)——功能评测非常全面

    替代 yunio , 推荐一个国外的云存储(同步盘) wuala 话说自从云诺开始收费后,我的文件便再没同步或备份过,前天没事便找了一下,发现一个国外的网盘,注册送 5 G 空间(对我来说同步日常文件 ...