PYTHTRIP - Pythagorean Triples
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
hide comments
karthik1997:
2015-07-15 09:20:07
tooo easy 5 lines of code :p |
|
Arkadiusz Bulski:
2012-08-02 23:37:51
I dare to challenge integrity of this one problem. Naive integers-based method does not work, while floating-point method does. This is just too weird... |
|
Miorel-Lucian Palii:
2009-10-26 13:29:41
hendrik, there are many problems for which the source limit does not prevent building look-up tables. Perhaps realizing you could do this was part of the trick?
|
|
hendrik:
2009-10-26 13:29:41
If they are simple you should at least limit the code size.
|
|
Ajay Nair:
2009-10-26 13:29:41
I dont mind the easier problems in the classical section, but hasnt the trend been off late that easier problems being shifted to tutorials ? for eg say very recently https://www.spoj.pl/problems/KZHAPPY/ was shifted , so even i would second pratiks opinion !! Well sorry but I am not really aware of the criteria for a problem being in tutorial or classical, i am just commenting on the trend that I have observed since I joined :) Last edit: 2009-10-19 18:03:02 |
|
Drew Saltarelli:
2009-10-26 13:29:41
*shrugs* If it's too easy for you, don't do it. |
|
Paranoid Android:
2009-10-26 13:29:41
To supplement Miorel's argument check out the problem MIRRORED. |
|
Miorel-Lucian Palii:
2009-10-26 13:29:41
There are easier problems in the classical section. |
|
.:: Pratik ::.:
2009-10-26 13:29:41
Please move to challenge(shortest code) or tutorial section. |
Added by: | Miorel Palii |
Date: | 2009-10-04 |
Time limit: | 1s |
Source limit: | 4096B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 C++ 4.3.2 ERL NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | University of Florida Local Contest - April 13, 2009 |