(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 ...
随机推荐
- HDU 5823 color II(FWT)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5823 [题目大意] 定义一张无向图的价值:给每个节点染色使得每条边连接的两个节点颜色不相同的最少颜 ...
- andrewchilds/jQuery.DomOutline
andrewchilds/jQuery.DomOutline DOM - 使用Javascript:让用户选择一个类似Firebug的HTML元素? -
- uva 10905 Children's Game (排序)
题目连接:uva 10905 Children's Game 题目大意:给出n个数字, 找出一个序列,使得连续的数字组成的数值最大. 解题思路:排序,很容易想到将数值大的放在前面,数值小的放在后面.可 ...
- ICE
一.Slice-to-C++映射 1.引言 其映射定义:怎样把Slice数据类型翻译成C++类型,客户怎样调用操作.传递参数.处理错误. C++映射完全是线程安全的.例如,类的引用机制针对并行访问机制 ...
- JQuery DataTable插件
参考文件: http://blog.csdn.net/xuechongyang/article/details/8424897 http://blog.csdn.net/llhwin2010/arti ...
- C#复习一( Twenty Days)
今天开始将要复习最近所学的一些C#知识.下面就来总结一下今天所复习的内容,以此来巩固我对C#知识的掌握.今天主要以举几个程序为例. 首先还是要注意代码的规范: –注释//,/**/,/// –骆驼 ...
- ##DAY7 UINavigationController
##DAY7 UINavigationController #pragma mark ———————UINavigationController——————————— 概括: 导航视图控制器也是一个视 ...
- Create a custom configSection in web.config or app.config file
config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> ...
- Page Cache, the Affair Between Memory and Files
Previously we looked at how the kernel manages virtual memory for a user process, but files and I/O ...
- 无法启动此程序,因为计算机中丢失QtCore4.dll。尝试重新安装该程序以解决此问题(在系统里添加3个路径)
解决方法: 计算机-属性-高级系统设置-高级-环境变量-系统变量-Path 添加 E:\Qt\4.8.5\bin; E:\Qt\4.8.5\qmake; E:\mingw\bin 重启计算机 http ...