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?

题目大意:

最小的两个具有两个不同质数因子的连续整数是:

14 = 2  7 15 = 3  5

最小的三个具有三个不同质数因子的连续整数是:

644 = 2²  7  23 645 = 3  5  43 646 = 2  17  19.

找出最小的四个具有四个不同质数因子的连续整数。它们之中的第一个是多少?

//(Problem 47)Distinct primes factors
// Completed on Thu, 13 Feb 2014, 12:50
// Language: C11
//
// 版权所有(C)acutus (mail: acutus@126.com)
// 博客地址:http://www.cnblogs.com/acutus/ #include<stdio.h>
#include<stdbool.h> int a[]; bool prim(int n)
{
int i;
for(i = ; i * i <= n; i++) {
if(n % i == ) return false;
}
return true;
} void init()
{
int i,j;
i = ;
j = ;
a[] = ;
while(j < ) {
if(prim(i)) a[j++] = i;
i += ;
}
} bool judge(int n)
{
int i, flag, count;
count = flag = ; for(i = ; i < ; i++) {
while(n % a[i] == ) {
flag = ;
n = n / a[i];
}
if(flag) count++;
flag = ;
if(count == ) return true;
}
return false;
} void solve()
{
int i;
for(i = ; i < ;) {
if(judge(i)) {
if(judge(i + )) {
if(judge(i + )){
if(judge(i + )){
printf("%d %d %d %d\n", i, i + , i + , i + );
return;
} else {
i += ;
continue;
}
} else {
i += ;
continue;
}
} else {
i += ;
continue;
}
} else {
i++;
}
}
} int main()
{
init();
solve();
return ;
}
Answer:
134043

(Problem 47)Distinct primes factors的更多相关文章

  1. (Problem 37)Truncatable primes

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

  2. (Problem 35)Circular primes

    The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...

  3. (Problem 29)Distinct powers

    Consider all integer combinations ofabfor 2a5 and 2b5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, ...

  4. (Problem 53)Combinatoric selections

    There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 2 ...

  5. (Problem 49)Prime permutations

    The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual ...

  6. (Problem 33)Digit canceling fractions

    The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...

  7. (Problem 73)Counting fractions in a range

    Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...

  8. (Problem 42)Coded triangle numbers

    The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangl ...

  9. (Problem 41)Pandigital prime

    We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...

随机推荐

  1. java面向对象编程(类、对象)

    一.面向对象编程概述面向对象编程(Object  Oriented  Programming,缩写为OOP)是当今最流行的程序设计技术,它具有代码易于维护.可扩展性好和代码可常用等优点.面向对象的设计 ...

  2. android开发_SimpleAdapter适配器

    android开发_SimpleAdapter适配器   新建项目: 项目结构: drawable-hdpi文件夹中的图片是自己加入的.主要是在菜单选项中显示的图片: 运行效果: 代码部分: main ...

  3. 对JAVA Bean使用PropertyDescriptor反射调用JAVA方法

    对于符合JAVA Bean规范的bean,调用其方法应优先使用java.beans.PropertyDescriptor获取Method进行方法调用,以获得更大的可维护性. 示比例如以下: NonCo ...

  4. BootStrap 智能表单系列 三 分块表单配置的介绍

    相信广大博友肯定碰到过一个编辑页面分了很多块的情况,智能表单插件已经为您支持了这种情况, 代码如下(链接地址:https://github.com/xiexingen/Bootstrap-SmartF ...

  5. sql Servers数据库基础

    1. 数据库约束包含:     ·非空约束     ·主键约束(PK) primary key constraint 唯一且不为空     ·唯一约束(UQ) unique constraint 唯一 ...

  6. ajax 上传图片 并预览

     <img {if !$article[pic]}style="display: none"{/if} width="82" height="6 ...

  7. BZOJ 2096: [Poi2010]Pilots( set )

    用个set维护就可以水过去...O(NlogN) 应该可以用单调队列O(N).... --------------------------------------------------------- ...

  8. HDU2007-平方和与立方和

    描述: 给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和. 代码: #include<stdio.h> #include<string.h> #include ...

  9. 指定字符串加密(对称加密DES)

    /* * @(#) EncrypAES.java */ import java.security.InvalidKeyException; import java.security.NoSuchAlg ...

  10. 我的Python成长之路---第一天---Python基础(4)---2015年12月26日(雾霾)

    五.数据运算与数据运算符 1.算术运算符 算术运算符 运算符 描述 示例 + 加法 >>> 14 - 5 9 - 减法 >>> 14 - 5 9  *  乘法 &g ...