#t210. 与圆相关的计算
与圆相关的计算
Circle Calculations
Problem Background
Special for beginners, ^_^
Problem Description
Given the radius of a circle, compute its diameter, circumference, and area.
Input Format
The input contains one real number (), the radius of the circle.
Output Format
Output one line with three numbers, representing the diameter, the circumference, and the area of the circle, separated by single spaces, each number kept to decimal places.
Sample Input
3.0
Sample Output
6.0000 18.8496 28.2743
Constraints
1s, 1024KiB for each test case.
Hint
- One line outputting three numbers, space-separated, each to decimal places.
- The precision of is the key to this problem: will already be wrong at the th decimal place — the official hint gives the
acos(-1)way, so just follow it.
You need a more precise value of . Add #include <cmath> (or <math.h> in C), and put the following line just above int main(): const double PI = acos(-1);
If the radius is , then the diameter, circumference, and area are 2*r, 2 * PI * r, and PI * r * r respectively.
You can keep decimal places with printf("%.4lf", ...) or cout << fixed << setprecision(4) << ....