(Problem 47)Distinct primes factors
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的更多相关文章
- (Problem 37)Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- (Problem 35)Circular primes
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...
- (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, ...
- (Problem 53)Combinatoric selections
There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 2 ...
- (Problem 49)Prime permutations
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual ...
- (Problem 33)Digit canceling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- (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 ...
- (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 ...
- (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 ...
随机推荐
- 一个关于Integer的秘密
先让大家看一段简单的代码: public static voidmain(String[] args) { Integera = 1; Integerb = 1; Integerc = 222; In ...
- 视频媒体播放,最好的 HTML 解决方法
最好的 HTML 解决方法 HTML 5 + <object> + <embed> <video width="320" height="2 ...
- uva 11134 - Fabled Rooks(问题转换+优先队列)
题目链接:uva 11134 - Fabled Rooks 题目大意:给出n,表示要在n*n的矩阵上放置n个车,并且保证第i辆车在第i个区间上,每个区间给出左上角和右小角的坐标.另要求任意两个车之间不 ...
- mysql中varchar最长多少
4.0版本以下,varchar(20),指的是20字节,如果存放UTF8汉字时,只能存6个(每个汉字3字节) 5.0版本以上,varchar(20),指的是20字符,无论存放的是数字.字母还是UTF8 ...
- 当x含有偶数个1,返回1,否则为0。
题目描述: /* Return 1 when x contains an even number of 1s;0 otherwise. Assume W=32 */ int even_ones(uns ...
- JS 原型 & 继承
理解原型链 先看看http://www.ituring.com.cn/article/56184和http://www.cavabiao.com/prototype-and-inherit-of-ja ...
- Round B APAC Test 2017
https://code.google.com/codejam/contest/5254487 A. Sherlock and Parentheses Problem Sherlock and Wat ...
- Windows Azure 网站自愈
编辑人员注释:本文章由 Windows Azure 网站团队的项目经理Apurva Joshi 撰写. 您有多少次在半夜被叫醒去解决一个仅需重新启动网站即可解决的问题?要是可以自动检测一些状况并自动恢 ...
- 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题
[HDU 3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...
- nginx自定义模块记录上游服务器特定响应头
功能,服务器通过扩展自定义命令,记录上游的服务器返回的特定响应头内容,记录到本地文件中 代码如下: /* * Copyright (C) Ciaos */ #include <ngx_confi ...