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的更多相关文章

  1. (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 ...

  2. (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 ...

  3. (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 ...

  4. (Problem 70)Totient permutation

    Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number ...

  5. (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 ...

  6. (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 ...

  7. (Problem 53)Combinatoric selections

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

  8. (Problem 49)Prime permutations

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

  9. (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 ...

随机推荐

  1. 转载 C# 序列化与反序列化意义详解

    C# 序列化与反序列化意义详解 总结: ①序列化基本是指把一个对象保存到文件或流中,比如可以把文件序列化以保存到Xml中,或一个磁盘文件中②序列化以某种存储形式使自定义对象持久化: ③将对象从一个地方 ...

  2. MFC数据类型(data types)

    为便于理解MFC库函数中的各种形参,现将MFC中常见的参数类型总结如下: 下面这些是和Win32程序(SDK程序)共同使用的数据类型: 数据类型 意义 BOOL Boolean值(布尔值,不是TRUE ...

  3. SQL Server索引进阶:第十三级,插入,更新,删除

    在第十级到十二级中,我们看了索引的内部结构,以及改变结构造成的影响.在本文中,继续查看Insert,update,delete和merge造成的影响.首先,我们单独看一下这四个命令. 插入INSERT ...

  4. JavaScript引用类型之Array数组的拼接方法-concat()和截取方法-slice()

    1.concat()   基于当前数组中的所有项创建一个新数组(也就是副本),然后将接收到的参数添加到副本的末尾,最后返回新构建的数组.也就是说,concat()在向数组中追加元素时,不会改变原有数组 ...

  5. JavaScript引用类型之Object类型

    在JavaScript中大多数的引用类型都是Object的实例,Object类型也是使用最多的类型! 创建Object类型实例的方式有两种,下面分别来分析一下: (1)第一种是使用new操作符后跟Ob ...

  6. Unity5UGUI 官方教程学习笔记(四)UI Image

    Image Source image:源图片  需要显示的图片 Color:颜色  会与图片进行颜色的混合 Material:材质 Image Type:  Simple   精灵只会延伸到适合Rec ...

  7. MarkDown使用 (三)表格

    MarkDown表格的用法 MarkDown表格的用法 例如: $$ \begin{array}{c|lcr} n & \text{Left} & \text{Center} & ...

  8. 条件注释+JS实现各版本IE浏览器className

    最近又开始忙了,项目中又遇到了可恶的IE Hack问题,各种Hack的看着让自己都觉得恶心,于是决定改造一番. 首先请出条件注释语句: 之前用过的条件注释 <!--[if lt IE 7]> ...

  9. 在CI框架下执行存储的方法

    我直接把代码摆在这里分享哈 <?php /** * * Created by JetBrains PhpStorm. * User: lsl * Date: 14-1-8 * Time: 下午2 ...

  10. hive原生和复合类型的数据载入和使用

    原生类型 原生类型包含TINYINT,SMALLINT,INT,BIGINT,BOOLEAN,FLOAT,DOUBLE,STRING,BINARY (Hive 0.8.0以上才可用),TIMESTAM ...