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. IOS系列——NStimer

    Timer经常使用的一些东西 1. 初始化 timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@select ...

  2. 为什么没有好用的Android游戏引擎?

    随着Android平台的不断发展,最近Android开发人员数量呈现出上升势头,就连以往较为冷门的游戏开发领域也涌现出不少生力军.然而,全新的问题正摆在了刚開始学习的人面前,非常多他们从未遇过的问题開 ...

  3. 自己写的操作sql的公共类

    /* /' `\/ `. . .' : `. `. \\.' , `.` `. `. ,___/|\. `. : . \, .'./ ' '\ , ' .\ . \_.~ _; ; \/'. `\ . ...

  4. eclipse 修改编码

    在Eclipse的开发使用中,我们经常使用的是UTF-8,但是刚刚安装的或者是导入的项目是其他编码的默认是GBK的,这就造成我们的项目乱码,一些中文解析无法查看,对我们的开发造成不便. 工具/原料 E ...

  5. activity的打开关闭动画

    Activity的打开关闭或者说相互跳转之间可以设置动画的.默认的打开关闭直接消失或出现,比较不优美,但是有的手机Rom对这个默认做了修改,比如红米HM1,默认的就是新页面自右向左滑动出现,自左向右滑 ...

  6. C# 如何从List集合当中取出子集合

    今天项目要求随机从数据库中随机取出若干条数据,放到首页.那么要如何随机取出这个子集合呢?本人向到的方法如下: 1.假设数据量很少,如我数据库中只有10条数据,而我要求随机取出8条.对于这种低数据量,大 ...

  7. c++ 11 vs 98

    在求最长子字符串中题中要遍历个上万字符数据 1.使用c++11代码 for (auto ch : s) { auto ss = vsi[ch]; vsi[ch].insert(i); i++; } 2 ...

  8. Oracle游标使用详解

    转自:http://www.cnblogs.com/sc-xx/archive/2011/12/03/2275084.html 声明游标:CURSOR cursor_name IS select_st ...

  9. LineCalc,一个基于Lex&Yacc的简单行计算工具

    LineCalc是基于Lex&Yacc的一个简单的行计算工具,支持常见的运算符和部分POSIX中定义于math.h中的数学函数:同时,LineCalc还提供了一个简单的错误处理模块,能检测公式 ...

  10. mysqldump 利用rr隔离实现一致性备份

    mysqldump -p -S /data/mysqldata1/sock/mysql.sock --single-transaction --master-data=2 --database db1 ...