游客 Signup | Login
中文 | En

2690 - 计算球的体积0

通过次数

0

提交次数

0

Time Limit : 2 秒 Memory Limit : 2048 MB

根据输入的半径值,计算球的体积。

Input

第一行输入一个T,代表有T组测试数据。接下来每行一个实数,表示球的半径

π取3.1415927


Output

输出对应的求的体积,计算结果保留三位小数。

Examples

Input Format

2
1
1.5

Output Format

4.189
14.137

Solution C

#include<stdio.h>
int main(){
	int i,T;
	double R,v;
	scanf("%d",&T);
	for(i=1;i<=T;i++){
		scanf("%lf",&R);
		v=3.1415927*R*R*R*4/3;
		printf("%.3lf\n",v);
	}
}

Solution C++

#include <stdio.h>
#define pi 3.1415927
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    double r;
    int t;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%lf",&r);
        double s;
        s=4*pi*r*r*r/3;
        printf("%.3f\n",s);
    }
    return 0;
}

Solution Java

import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner reader=new Scanner(System.in);
		double PI=3.1415927;
	    int T=reader.nextInt();
	    for(int i=0;i<T;i++){
	      double a=reader.nextDouble();
	      double b=a*a*a*PI*(4.0/3.0);
	      System.out.printf("%.3f",b);  
	      System.out.println();
	    }
	  }
}