PiCalculator
SRM 246 · 2005-06-09 · by Andrew_Lazarev
Problem Statement
The problem statement contains the unicode symbols.
You are developing a new software calculator. A very important feature is the auto-placing of the ? value by one click. The only problem is that you don't know the required precision. That's why you decided to write a program that can return ? with any reasonable precision.
You are given an
Notes
- ? equals 3.141592653589793238462643383279...
Constraints
- precision will be between 1 and 25, inclusive.
2 Returns: "3.14"
4 Returns: "3.1416"
The value should be rounded.
12 Returns: "3.141592653590"
Be careful with rounding.
1 Returns: "3.1"
3 Returns: "3.142"
Submissions are judged against all 32 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class PiCalculator with a public method string calculate(int precision) · 32 test cases · 2 s / 256 MB per case