2018 Beijing University of Information Science and Technology 10th Program Design Competition and ACM Selection Competition-B-precise math function

Topic description

 
  A PBY student who loves ACM has encountered a mathematical problem. Knowing the base n, please help him accurately calculate the result a = n π (n to the power of π), and keep the result with x digits after the decimal point.

Enter description:

The first line is an integer t, representing the number of test instances; then there are t lines of input data, each line contains two positive integers n and x, representing the base and the number of reserved digits. (1 <= t <= 100, 1 <= n <= 500, 1 <= x <= 6)

Output description:

For each set of input data, output the result a separately, and each output occupies one line.
Example 1

enter

3
1 3
7 6
9 1

output

1.000
451.807873
995.0 
Problem-solving ideas: Water passes! seconds!
AC code:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define PI acos(-1.0)
 4 int main(){
 5     int t,n,x;
 6     cin>>t;
 7     while(t--){
 8         cin>>n>>x;
 9         double r=pow(n,PI);
10         cout << setiosflags(ios::fixed) << setprecision(x) << r << endl;
11     }
12     return 0;
13 }
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325310899&siteId=291194637