#include <stdio.h>
#include <stdlib.h>
double f(double c){
if((0<=c)&&(c<=50)){
return 1.0/50*c;}
else if(50<c){
return 1.0;}
return -1.0;
}
double g(double c){
if((0<=c)&&(c<=20)){
return 1.0;}
else if((20<c)&&(c<=40)){
return -1.0/20*c+2.0;}
else if(40<c){
return 0.0;}
return -1.0;
}
double p(double x){
if((0<=x)&&(x<=20)){
return 0.0;}
else if((20<x)&&(x<=40)){
return 1.0/20*x-1.0;}
else if((40<x)&&(x<=60)){
return -1.0/20*x+3.0;}
else if(60<x){
return 0.0;}
return -1.0;
}
double q(double x){
if((0<=x)&&(x<=40)){
return 0.0;}
else if((40<x)&&(x<=60)){
return 1.0/20*x-2.0;}
else if((60<x)&&(x<=80)){
return -1.0/20*x+4.0;}
else if(80<x){
return 0.0;}
return -1.0;
}
double min(double a,double b){
if(a<=b){return a;}
else if(b<a){return b;}
return -1;
}
double max(double a,double b){
if(a<=b){return b;}
else if(b<a){return a;}
return -1;
}
double s(double c,double x){
return max(min(f(c),p(x)),min(g(c),q(x)));
}
double ans(double w,double st,double en,double c){
double i=st,s1=0.0,s2=0.0;
while(i<=en){
s1=s1+s(c,i);
i=i+w;
}
i=st;
while(i<=en){
s2=s2+(i*s(c,i));
i=i+w;
}
return s2/s1;
}
int main(void) {
double c,w;
printf("c=");
scanf("%lf", &c);
printf("w=");
scanf("%lf", &w);
printf("ans=%lf", ans(w,0,100,c));
return 0;
}
/********************************************/
c=30
w=10
ans=49.615385
c=43
w=10
ans=40.000000
/********************************************/