SPOJ Problems 2

CAn you help to solve this :

4906. Pythagorean Triples
Problem code: PYTHTRIP

A Pythagorean triple (A, B, C) is defined as three positive integers that satisfy the Pythagorean Theorem: A2 + B2 = C2. Given two positive integers A and B, your task is to verify whether they are the "legs" in a Pythagorean triple, i.e. if an integer C exists such that (A, B, C) is a Pythagorean triple.
Input

The first line will contain a single integer N (0 < N <= 10000). Each of the next N lines will contain two integers A and B (0 < A, B <= 100).
Output

For each test case, output a single line. If a valid C exists, output a line containing the word YES and the value of C, separated by a space. Otherwise, output the single word NO.
Example

Input:
4
2 2
4 3
4 5
5 12

Output:
NO
YES 5
NO
YES 13
This isn't a homework service. Try to solve it yourself first. If you're stuck with a specific thing, show us your code and tell us what's giving you trouble, and we'll help you through it.

But we're not going to do the assignment for you.
Topic archived. No new replies allowed.