2692The Gougu Theorem

2692   The Gougu Theorem

题目描述

Pythagorean Theorem is "humanity's greatest scientific discoveries of the ten" is a basic elementary geometry theorems.  "This theorem has a very long history, almost all ancient civilizations (Greece, China, Egypt, Babylon, India, etc.) have studied this theorem. Pythagorean Theorem in the West known as the Pythagorean Theorem, are said to Ancient Greek mathematician and philosopher Pythagoras (Pythagoras, BC572 ~ BC497) was first discovered in BC550.

Pythagorean Theorem in China known as the Gougu/勾股 Theorem. Around 1100 BC, the Western Zhou period, the ancient Chinese mathematician, Shanggao, first described the Gougu Theorem. In the famous ancient mathematics book, 《九章算术》,the proof was given  (left). The Gougu Theorem is that "in the right triangle, the sum of the squares of two right sides is equal to the square of the hypotenuse." In other words, the three sides (a, b, c) of right-angled triangle satisfies the following equation:

a2+b2=c2

Where a is called /Gou, b is /Gu, and c is /Xian.

For given c, how many different positive integer solutions are there? ((a,b,care relatively-prime. ) It is an interesting problem.

Now, your task is to solve it.

输入格式:

There are several test cases; each test case contains one positive integer c (0 < c < 230 ) in a line. c = 0 is the end of input and need not to process.

输出格式:

For each test case, your program should output by following format:

Case #:

There are n solution(s).

a^2 + b^2  =  c^2

…..(total n line(s) )….

 

Where # is the test case number starting from 1, two consecutive cases should be separated by a single blank line.

For each given c, output all solutions satisfying:

a2+b2=c2

Each solution should be in one line, and in order a<b<c.

You should output n solutions by ascending order of a.

输入样例 复制
65
20
0
输出样例 复制
Case 1:
There are 2 solution(s).
16^2 + 63^2 = 65^2
33^2 + 56^2 = 65^2

Case 2:
There are 0 solution(s).

说明

1
2
通过提交
时空限制1000ms/128mb
题目来源2010湖大校赛
评测方式在线评测
题目类型
难        度