Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/begin-kosinuslar-teoremasi

Law of cosines

Medium 1000 ms 64 MB 39%
Share

Two sides of a triangle $a$, $b$ and the angle $\gamma$ between them (in degrees) are given. Find the third side $c$ and the area $S$ of the triangle:

$$c = \sqrt{a^{2} + b^{2} - 2 * a * b * \cos \gamma}, \qquad S = \frac{1}{2} * a * b * \sin \gamma$$

Use $\pi = 3.141592653589793$.

A triangle: angle gamma between sides a and b, side c opposite it

Input

One line with three positive integers: $a$, $b$ and $\gamma$.

Output

One line with two numbers: $c$ and $S$, each with exactly 2 digits after the decimal point (for example, 5.00).

Note

$1 \le a, b \le 1000$
$1 \le \gamma \le 179$

Examples

Input #1
3 4 90
Output #1
5.00 6.00
Input #2
5 5 60
Output #2
5.00 10.83

Sign in to submit a solution

Signing up is free and takes a minute.