(Problem 9)Special Pythagorean triplet
A Pythagorean triplet is a set of three natural numbers, a
b
c, for which,
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的更多相关文章
- (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 46)Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...
- (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 ...
随机推荐
- Delphi中的内存对齐 与 Packed关键字
以delphi为例:TTest = recordc1: char;i1: Integer;c2: char;c3: Char;end;这个结构如果用sizeof取其占用的内存大小,是多少呢,是1+4+ ...
- SQL中采用Newtonsoft.Json处理json字符串
原文 SQL中采用Newtonsoft.Json处理json字符串 使用环境: SQL Server2005; VS2010; 关于SQL中部署CLR程序集的方法,网上一搜一大把,需要了解的自行查阅, ...
- php 前台数据显示
<pre name="code" class="html"> public function show(){ echo "访问了index ...
- perl5 第七章 控制结构
第七章 控制结构 by flamephoenix 一.条件判断二.循环: 1.while循环 2.until循环 3.for循环 4.针对列表(数组)每个元素的foreach循环 5. ...
- JavaEE Tutorials (10) - Java持久化查询语言
10.1查询语言术语14010.2使用Java持久化查询语言创建查询141 10.2.1查询中的命名参数142 10.2.2查询中的位置参数14210.3简化的查询语言语法142 10.3.1选择语句 ...
- 关于GROUP BY的应用
前面收藏了别人的SQL语句操作,可是没有实战,也未知学的如何 正好今天有个事需要做一下 (sql server 2000) 三个表:stuInf,sType,sinInf分别为学生信息表,类型表,信息 ...
- SQL中的Update、delete与inner join 联合使用
Update XXX set XXX where 这种写法大家肯定都知道,才发现update和delete居然支持inner join的update方式,太神奇了. update的格式是 update ...
- DevExpress ASP.NET 使用经验谈(2)-XPO对象的使用(使用默认数据连接)
接下来,我们通过一个控制台应用程序,介绍XPO对象的保存操作. 图一 添加新项目 图二 选择项目类型为控制台应用程序 查看生成的Program.cs代码文件,代码如下: using System; u ...
- Dapper 多数据库优化
Dapper是近2年异军突起的新ORM工具,它有ado.net般的高性能又有反射映射实体的灵活性,非常适合喜欢原生sql的程序员使用,而且它源码很小,十分轻便.我写本博客的目的不是为了介绍Dapper ...
- [LeetCode]题解(python):018-4Sum
题目来源: https://leetcode.com/problems/4sum/ 题意分析: 这道题目和3Sum的题目类似,找出所有的4个数,使得这4个数等于target. 题目思路: 这道题做法和 ...