HZNUOJ

The Gougu Theorem

Tags:
Time Limit:  2 s      Memory Limit:   32 MB
Submission:77     AC:24     Score:99.35

Description

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,c)are relatively-prime. ) It is an interesting problem.

Now, your task is to solve it.

Input

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. 

Output

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

Samples

input
65 20 0
output
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).

Source

湖南大学2010校赛