Triangle Classification (APCS 2016-10 Beginner)

Points 100 1.0s 256M

Besides being the most basic polygon, a triangle can be further classified as an obtuse triangle, a right triangle, or an acute triangle. Given the lengths of three segments, the following formulas determine whether the three segments can form a triangle, and if so, which type it is.

Hint: let \(a\), \(b\), \(c\) be the three segment lengths with \(c\) being the largest. Then

  • If \(a + b \le c\), the three segments cannot form a triangle
  • If \(a^2 + b^2 < c^2\), the three segments form an obtuse triangle
  • If \(a^2 + b^2 = c^2\), the three segments form a right triangle
  • If \(a^2 + b^2 > c^2\), the three segments form an acute triangle

Write a program that reads the lengths of three segments, determines whether they can form a triangle, and if so, outputs the type of the triangle.

Input

The input consists of a single line containing three positive integers, separated by exactly one space.

Constraints:

  • All three positive integers are less than \(30001\) (i.e. between \(1\) and \(30000\))

Output

Output two lines:

The first line prints the three positive integers in non-decreasing order, with exactly one space between adjacent numbers and no trailing space after the last number;

The second line prints the type of the triangle:

  • If the segments cannot form a triangle, print No;
  • If they form an obtuse triangle, print Obtuse;
  • If they form a right triangle, print Right;
  • If they form an acute triangle, print Acute.

Scoring

The time limit for each test case is \(1\) second; your score is the sum over the test cases you pass.

Sample Input 1

3 4 5

Sample Output 1

3 4 5
Right

Sample Explanation 1

When \(a^2 + b^2 = c^2\) holds, it is a right triangle.

Sample Input 2

101 100 99

Sample Output 2

99 100 101
Acute

Sample Explanation 2

The side lengths are printed in non-decreasing order; when \(a^2 + b^2 > c^2\) holds, it is an acute triangle.

Sample Input 3

10 100 10

Sample Output 3

10 10 100
No

Sample Explanation 3

Since the segments cannot form a triangle, the second line must print No.

Source

APCS programming exam, October 29, 2016, Problem 1.

Problem page help

Keyboard shortcuts

Main features

  • Sample tests — Runs the sample cases bundled with the problem and auto-compares against the expected output.
  • Custom test — Run your code with your own stdin. Optionally tick the "Compare with expected (diff)" box to verify against expected output line-by-line.
  • Template — Paste the default code template you set on your profile page.
  • Collab — Edit this problem together with classmates in real time.
  • Auto-draft — Editor contents auto-save to your browser every 1.5 seconds (per account / problem / language).
  • Submit — Send your code to the judge for grading; returns AC / WA / TLE etc.

Limits

  • Source code: at most 65,536 characters
  • Custom test stdin and expected output: at most 1 MB each (≈1 million characters)
  • Custom test and sample test share the sandbox; about 1 request per 3 s per user (sample test: 1 per 1 s)
  • Custom test and sample test both have a 15 second wall-clock cap (the official judge still uses the problem time limit)
  • Interactive problems do not offer custom test (cannot simulate interaction with the judge).
  • Submitting has no rate limit, but rapid repeated submissions on the same problem are treated as score farming.