It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.
9 = 7 + 212
15 = 7 + 222
21 = 3 + 232
25 = 7 + 232
27 = 19 + 222
33 = 31 + 212
It turns out that the conjecture was false.
What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?
题目大意:
Christian Goldbach 提出每个奇合数都可以写作一个质数与一个平方数的二倍之和:
9 = 7 + 212
15 = 7 + 222
21 = 3 + 232
25 = 7 + 232
27 = 19 + 222
33 = 31 + 212
但是这个推测是错误的。
最小的不能写作一个质数与一个平方数的二倍之和的奇合数是多少?
//(Problem 46)Goldbach's other conjecture
// Completed on Fri, 26 Jul 2013, 16:58
// Language: C11
//
// 版权所有(C)acutus (mail: acutus@126.com)
// 博客地址:http://www.cnblogs.com/acutus/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdbool.h> bool issquare(int n) //判断一个自然数是否为一个平方数
{
if(ceil(sqrt(n))*ceil(sqrt(n))==n) return true;
else return false;
} bool isprim(int n) //素数判断
{
for(int i=; i*i<=n; i++)
{
if(n%i==) return false;
}
return true;
} bool judge(long long n)
{
int i=;
long long t;
while((t=(n-*(i*i)))>)
{
if(isprim(t)) return true;
i++;
}
return false;
} int main()
{
for(long long i=; i<; i=i+)
{
if(!isprim(i) && !judge(i))
{
printf("%lld\n",i);
break;
}
}
return ;
}
Answer:
|
5777 |
(Problem 46)Goldbach's other conjecture的更多相关文章
-
(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 ...
-
(Problem 70)Totient permutation
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number ...
-
(Problem 74)Digit factorial chains
The number 145 is well known for the property that the sum of the factorial of its digits is equal t ...
-
(Problem 72)Counting fractions
Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...
-
(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 47)Distinct primes factors
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 7 15 = 3 5 The fi ...
随机推荐
-
显示pdf
document.all[document.all.PDFNotKnown ? "IfNoAcrobat" : "IfAcrobat"].style.displ ...
-
objectARX 获取指定图层上所有实体ID
2015-12-17 //获取指定图层上所有实体ID AcDbObjectIdArray GetAllEntityId(const TCHAR* layername) { AcDbObjectIdAr ...
-
winform DataGridView控件判断滚动条是否滚动到当前已加载的数据行底部 z
http://www.zuowenjun.cn/post/2015/05/20/162.html 判断 DataGridView控件滚动条是否滚动到当前已加载的数据行底部,其实方法很简单,就是为Dat ...
-
HDFS的体系结构和操作
1.对hdfs操作的命令格式是hadoop fs 1.1 -ls <path> 表示对hdfs下一级目录的查看 1.2 -lsr <path> 表示对hdfs目录的递归查看 1 ...
-
SCCM2007
Active Directory系统组发现:此方法按照上次运行发现方法时 Active Directory 中的响应返回对象,可发现活动目录OU.全局组.通用组.嵌套组.非安全组. Active Di ...
-
Android性能优化之如何避免Overdraw
什么是Overdraw? Overdraw就是过度绘制,是指在一帧的时间内(16.67ms)像素被绘制了多次,理论上一个像素每次只绘制一次是最优的,但是由于重叠的布局导致一些像素会被多次绘制,而每次绘 ...
-
微信超时5s,调用客服接口异步回复消息(PHP)
当用户触发事件,如果不能保证在5s内响应,可以先返回success,然后异步调用返回的信息.代码如下: // 立即返回(异步执行) ignore_user_abort(true);//start=== ...
-
Redis缓存穿透、缓存雪崩和缓存击穿理解
1.缓存穿透(不存在的商品访问数据造成压力) 缓存穿透,是指查询一个数据库一定不存在的数据.正常的使用缓存流程大致是,数据查询先进行缓存查询,如果key不存在或者key已经过期,再对数据库进行查询,并 ...
-
POJ2392 Space Elevator
题目:http://poj.org/problem?id=2392 一定要先按高度限制由小到大排序! 不然就相当于指定了一个累加的顺序,在顺序中是不能做到“只放后面的不放前面的”这一点的! 数组是四十 ...
-
select()函数用法三之poll函数
poll是Linux中的字符设备驱动中有一个函数,Linux 2.5.44版本后被epoll取代,作用是把当前的文件指针挂到等待队列,和select实现功能差不多. poll()函数:这个函数是某些U ...