//
Chelsea Zhang
//
Senior Division Contest 1
//
Montgomery Blair High School #7096
import
java.io.*;
public
class PostOffice
{
static double l, h, t;
static int start, end;
static String cost()
{
int
n = Math.abs(zone(start)-zone(end));
double
cost = 0;
if(within(l,3.5,4.25)
&& within(h,3.5,6) && within(t,0.007,0.016))
cost = .20+0.03*n;
else
if(within(l,4.25,6) && within(h,6,11.5) &&
within(t,0.007,0.016))
cost = .37+0.03*n;
else
if(within(l,3.5,6.125) && within(h,5,11.5) &&
within(t,0.016,0.25))
cost = .37+0.04*n;
else
if(within(l,6.125,24) && within(h,11,18) && within(t,0.25,0.5))
cost = .60+0.05*n;
else
if(l >= 6.125 && h >= 11 && t >= 0.25)
{
if(l+2*(h+t) <= 84)
cost
= 2.95+0.25*n;
else if(l+2*(h+t) <= 130)
cost
= 3.95+0.35*n;
}
if(cost
< 0.20)
return "UNMAILABLE";
String
output = Double.toString(cost);
if(output.indexOf(".")
< 0)
output += ".";
while(output.length()-1
- output.indexOf(".") < 2)
output += "0";
return
output;
}
static int zone(int num)
{
if(within(num,1,6999))
return 1;
else
if(within(num,7000,19999))
return 2;
else
if(within(num,20000,35999))
return 3;
else
if(within(num,36000,62999))
return 4;
else
if(within(num,63000,84999))
return 5;
else
if(within(num,85000,99999))
return 6;
return
-1;
}
static boolean within(double x,
double a, double b)
{
return
(x >= a && x <= b);
}
public static void main(String[]
args) throws IOException
{
System.err.println("Please
enter each line of input separated by commas and spaces, like this:");
System.err.println("4,
4, .009, 02893, 08516");
BufferedReader
reader = new BufferedReader(new InputStreamReader(System.in));
StreamTokenizer
st = new StreamTokenizer(new BufferedReader(reader));
while(true)
{
st.nextToken();
l = st.nval;
st.nextToken();
st.nextToken();
h = st.nval;
st.nextToken();
st.nextToken();
t = st.nval;
st.nextToken();
st.nextToken();
start = (int)st.nval;
st.nextToken();
st.nextToken();
end = (int)st.nval;
System.out.println(cost() +
"\n");
}
}
}