[HDU] [2002] Calculate the Volume of a Sphere

Problem Description

Loading...

Problem Analysis

I didn’t use pow because apparently a function call isn’t as fast as doing the multiplication directly…

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include<stdio.h>
#define PI 3.1415927
int main()
{
    double V,r;
    while(scanf("%lf",&r)!=EOF)
    {
        V=(PI*r*r*r*4)/3;
        printf("%.3lf\n",V);
    }
return 0;
}

Loading...