#!/bin/bash
read a # 500
read b # 100
read c # 50
read x # target
c=0
cc=0
for ((ia=0; ia <= $a; ia++)); do
  for ((ib=0; ib <= $b; ib++)); do
    for ((ic=0; ic <= $c; ic++)); do
      echo $ia
      echo $ib
      echo $ic
      cc=$(($cc+1))
      #echo AAA
      #echo $((500*$ia+100*$ib+50*$ic))
      echo $(($((500*$ia))+$((100*$ib))+$((50*$ic))))
      if [ $(($((500*$ia))+$((100*$ib))+$((50*$ic)))) == $x ];then
        c=$(($c+1))
      fi
    done
  done
done
echo $c
echo XXXXXXX
echo $cc