Blue Bridge Cup entry area of a circle training questions

Getting questions training area of ​​a circle

Resource limitation
time limit: 1.0s memory limit: 256.0MB
problem description
to a circle of a given radius r, of circular area.
Input format
input contains an integer r, represents the radius of the circle.
Output format
output line, comprising a real number, rounded to 7 after the decimal point indicates the area of a circle.
Description: In this problem, the input is an integer, but the output is a real number.

For the problem of real output, be sure to look at the requirements of real output, such as required in this question after seven decimal places, then your program must be strictly output seven decimal places, too much or too little output of decimal places are not , it will be considered an error.

The real question is if the output is not specified, rounding is performed by rounding.

Input Sample
4
Sample Output
50.2654825
data size and Conventions
1 <= r <= 10000.
Prompt
this question of high precision, please note that the value of π should take a more accurate value. You can use constants to represent π, for example PI = 3.14159265358979323, mathematical formulas may be used to seek π, such as PI = atan (1.0) * 4 .

Ideas: The title round formula for π multiplied by the square of r, pay attention to retain the decimal places on the line. (C ++ reserved behind the decimal places of library functions is: iomanip)

code show as below:

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
#define m atan(1.0)*4
int main(){
	int n;
	cin>>n;
	cout<<fixed<<setprecision(7)<<n*n*m;
}
Published 51 original articles · won praise 47 · views 2009

Guess you like

Origin blog.csdn.net/weixin_45269353/article/details/104559690