A Pythagorean triplet is a set of three natural numbers, a  b  c, for which,

a2 + b2 = c2

For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdbool.h> void show()
{
int a,b,c;
for(a=; a<; a++)
{
for(c=; c<; c++)
{
b=-a-c;
if(a*a+b*b==c*c)
{
printf("%d\n",a*b*c);
return;
}
}
}
} int main()
{
show();
return ;
}
Answer:
31875000

(Problem 9)Special Pythagorean triplet的更多相关文章

  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 46)Goldbach's other conjecture

    It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...

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

  8. (Problem 53)Combinatoric selections

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

  9. (Problem 49)Prime permutations

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

随机推荐

  1. A Byte of Python 笔记(6)模块

    第8章 模块 用户在程序中定义一次函数而重用代码,如果用户想在其他程序中重用很多函数,可以通过使用模块的方式. 模块就是一个包含了所有用户定义的函数和变量的文件.为了在其他程序中重用模块,模块的文件名 ...

  2. QT IP输入框正则表达式(使用QLineEdit的setValidator函数)

    /* ip输入框正则表达式 */ // IP 前3段 QRegExp regExp("[0-9][0-9.][0-9.][.]"); ui->lineEdit_1->s ...

  3. TreeView控件例子

    XmL文件代码: <?xml version="1.0" encoding="utf-8" ?> <Area> <Province ...

  4. linux-0.11抠代码-GDB+VMWARE

    vmware新建一个虚拟机,硬盘为0.1G,建立完成后要先启动一次虚拟机,此时无任何系统,然后再关闭,应该会多出一个ostest-flat.vmdk这个虚拟磁盘文件,下面要用到 新建完成后 我的虚拟机 ...

  5. HDU 1507 Uncle Tom's Inherited Land*

    题目大意:给你一个矩形,然后输入矩形里面池塘的坐标(不能放东西的地方),问可以放的地方中,最多可以放多少块1*2的长方形方块,并输出那些方块的位置. 题解:我们将所有未被覆盖的分为两种,即分为黑白格( ...

  6. C++模板:文件操作

    freopen("demo.in","r",stdin); freopen("demo.out","w",stdout) ...

  7. makefile 里面 := 和 = 的区别

    此文版权属于作者所有,任何人.媒体或者网站转载.借用都必须征得作者本人同意! 参考:What is the colon equals sign ( := ) in makefiles? Makefil ...

  8. hdu4300之KMP&&EKMP

    Clairewd’s message Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  9. java的大数类

    java中的大数类,真的很方便,不用自己再写计算的函数,先写一个简单的例子,以后再补充 注意大数初始化的时候,参数十字符型的,如果传进去的变量十一个数字,需要加上一个空字符即:+"" ...

  10. 【MFC相关】图片显示

    CPaintDC dc(this); if (!m_hBitmap) return; image.Attach(m_hBitmap); CRect rect; GetClientRect(&r ...