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

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, indicating the number of test instances;
Then there are t lines of input data, each line containing 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

Note the usage of printf. Click to open the link for details

In order to ensure the accuracy of the value of pi, it is best to use the inverse cosine function acos(-1) to take it.

#include<stdio.h>
#include<math.h>
const double pi = acos(-1);
intmain()
{
    int t,n,x;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&x);
        double sum = pow(n,pi);
        printf("%.*f\n",x,sum);
    }
    return 0;
}

Guess you like

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