Spoj PRISMSA solution

By | October 2, 2016

Spoj PRISMSA solution. Spoj TRIANGULAR PRISM solution.

Category: AdHoc, Math, Formula

This question is of minimization of Surface Area for a Triangular Prism whose volume is given.
Applying the standard differentiating procedure, the value of “a” comes out to be:

a = (4V)1/3  , h = a/ sqrt(3)

Putting the values together, we get:

Surface Area = 3*a*a*sqrt(3) / 2;

Using this, the minimum surface area can be calculated.

Spoj PRISMSA solution code:

using namespace std;

int main()
    int t;
    double vol,surface_area,a;
        /*the value of a calculated for minimum 
        Surface Area*/
        a = pow(4*vol,0.3333333333333333333333333);
        surface_area = 3*a*a*sqrt(3)/2;
        cout << std::fixed << std::setprecision(10) << surface_area<<"\n";
    return 0;