{

Filip Barl

V. gimnazija

Intermediate division

}

 

#include <cstdio>

#include <cstdlib>

#include <cmath>

 

#define N         5

 

double func(double len, double wid, double thick, double weight) {

       //REGULAR POST CARD

       if(len>=3.5 && len<=4.25 && wid>=3.5 && wid<=6.0 && thick>=0.007 && thick<=0.016)

            return (ceil(weight/0.0625)*0.20);

       //LARGE POST CARD

       else if(len>4.25 && len<6.0 && wid>6.0 && wid<11.5 && thick>=0.007 && thick<=0.016)

            return (ceil(weight/0.0625)*0.30);

       //ENVELOPE

       else if(len>=3.5 && len<=6.125 && wid>=5.0 && wid<=11.5 && thick>0.016 && thick<0.25)

            return (ceil(weight/0.0625)*0.47);

       //LARGE ENVELOPE

       else if(len>6.125 && len<24.0 && wid>=11.0 && wid<=18.0 && thick>=0.25 && thick<=0.5)

            return (ceil(weight/0.0625)*0.56);

       //PACKAGE

       else if( (len>=24.0 || wid>18.0 || thick>0.5) && (len+2.0*(thick+wid))<=84.0)

            return (ceil(weight/0.5)*1.50);

       //LARGE PACKAGE

       else if( (len+2.0*(thick+wid))>84.0 && (len+2.0*(thick+wid))<=130.0)

            return (ceil(weight/0.5)*1.75);

       //UNMAILABLE

       else return (-1.0);

}

 

int main(void) {

    int i;

    double len,wid,thick,weight,rez;

    for(i=0;i<N;i++) {

        scanf("%lf,%lf,%lf,%lf",&len,&wid,&thick,&weight);

        rez=func(len,wid,thick,weight);

        if(rez==-1.0) printf("UNMAILABLE\n"); else printf("%.2lf\n",rez);

    }

    return 0;  

}