Tuesday, 16 April 2019

Juice in the Glass LightOj 1216

In this problem we need to just find a equation,
a equation called conic  frustrum volume:
         
           V  = (pi*h /3) *(R*R + R*r + r*r)

code(c++):

/*
Author : Mohammad Morsalin Hossain
Dept of ICE,NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define pi acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int main()
{
    IOS
    int test,to=0;
    cin>>test;
    while(test--)
    {
        int r1,r2,h,p;
        cin>>r1>>r2>>h>>p;
        double pr= r2 +(r1-r2)*((double)p/h);
        double v;
        v = (pi*p)*(((double)pr*(double)pr)+((double)pr*(double)r2)+((double)r2*(double)r2))/3.0;
        printf("Case %d: %lf\n",++to,v);
    }
    return 0;
}



No comments:

Post a Comment

If you have any doubts, let me know through comments

Monkey Banana Problem lightoj 1004

  In this problem we will check which adjacent cell will benefits the monkey best. For this, we will check all possible solution of this pro...