UVa 11855 - Buzzwords

11855 - Egypt

 * http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2954

Summary
Just see whether or not a triangle is a right triangle use all three sides as the hypotenuse once.

Explanation
A very simple problem that tests simple I/O syntax, and whether or not you know the Pythagorean theory.

Optimizations
None necessary.

Gotchas

 * The lengths of the sides are not given in any particular order, so any side can be the hypotenuse.

Input
6 8 10 25 52 60 5 12 13 0 0 0

Output
right wrong right

Solutions
Java: import java.util.Scanner;

public class Main{ public static void main(String args[]){ Scanner in = new Scanner(System.in); do{ int a = in.nextInt, b = in.nextInt, c = in.nextInt; if(a == 0 && b == 0 && c == 0) break; System.out.println(a * a + b * b == c * c ? "right" : a * a + c * c == b * b ? "right" : b * b + c * c == a * a ? "right" : "wrong"); }while(true); in.close; } }