DegreesToRadians
SRM 342 · 2007-03-14 · by Kawigi
Problem Statement
In some forms of geometry, like the kind used in geographical longitude/latitude measurements, angles are measured in base-60. The base unit is the degree. One degree contains 60 minutes, and one minute contains 60 seconds.
You will be given the measurement of an angle in degrees, minutes, and seconds. Return the given angle in radians. Note that n degrees is equal to n*PI/180 radians.
Notes
- The return value must have an absolute or relative error less than 1e-9.
Constraints
- degrees will be between 0 and 359, inclusive.
- minutes will be between 0 and 59, inclusive.
- seconds will be between 0 and 59, inclusive.
0 0 0 Returns: 0.0
Zero is zero, in either measurement system.
180 0 0 Returns: 3.141592653589793
180 degrees is PI radians.
359 59 59 Returns: 6.283180459042776
This is as close to a full circle as it gets.
23 30 5 Returns: 0.41017661490272295
198 49 40 Returns: 3.470199366645837
Submissions are judged against all 106 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class DegreesToRadians with a public method double convertToRadians(int degrees, int minutes, int seconds) · 106 test cases · 2 s / 256 MB per case