URI Online Judge Solution| 1011 Sphere

Problem Link: https://www.urionlinejudge.com.br/judge/en/problems/view/1011
Solution:

I first tried to do with float but it was not giving me correct answer for 3rd test case so i have searched in the net for solution the i have seen that i have to use double as double is for 8 byte where as float was for 4 byte

So i have used float and result is correct upto all test cases 🙂

#include<iostream>
#include<cstdio>
int main()
{
int R;
double volume,value,pi=3.14159;
scanf("%d",&R);
volume=(4/3.0*pi*R*R*R);
printf("VOLUME = %.3lf\n",volume);
return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *