eolymp
bolt
Try our new interface for solving problems
Problems

Area of Regular Polygons

Area of Regular Polygons

The formula to compute the area of regular polygon with \textbf{n} sides and side-length of \textbf{s} is: \includegraphics{https://static.e-olymp.com/content/3b/3bebc3caa74a8f7ddb1c8531646cd71b2943fa28.jpg} . Your task is to use this formula to calculate the areas of regular polygons. You are also asked to print appropriate error messages for problematic input cases. \InputFile The first input line contains the number of test cases \textbf{N}, \textbf{1} ≤ \textbf{N} ≤ \textbf{50}. Each test case begins with a line containing two integer \textbf{n} and \textbf{s}, separated by space. \begin{itemize} \item \textbf{n} is the user input for the number of sides, and satisfies \textbf{−100} ≤ \textbf{n} ≤ \textbf{100}. \item \textbf{s} is the user input for the length of each side, and satisfies \textbf{−100} ≤ \textbf{s} ≤ \textbf{100}. \end{itemize} \OutputFile For each test case, print an error message or the area (if no errors are found) on a single line. If \textbf{n} is zero or negative then print the message "\textbf{Number of sides must be positive}". Otherwise, if \textbf{n} is strictly less than \textbf{3}, then print "\textbf{Need more sides}". Otherwise, if \textbf{s} is zero or negative then print "\textbf{Side length must be positive}". Otherwise the input is valid, and you are asked to print the area of the regular polygon described by the input, to \textbf{4} decimal places.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
4 1
3 10
-10 10
10 -10
Output example #1
1.0000
43.3013
Number of sides must be positive
Side length must be positive
Source University of Toronto 2010 ACM Tryout: Saturday, October 2, 2010