implicit none
integer :: a,b,c,d,e,f,n_a,i,j,k,l
double precision :: youeki, yousitu,noudo,Li,S,T

read(5,*) a,b,c,d,e,f
youeki=0
yousitu=0
noudo=0
n_a=int(f/(100*a))

do i=0, 2+n_a
do j=0, 2+int((f-100*i*a)/(100*b))
do k=0, 2+int((f-100*i*a-100*j*b-k*c)/d)
do l=0, 2+int((f-100*i*a-100*j*b-k*c)/d)
    S=100.0*a*i+100.0*b*j+c*k+d*l
    T=c*k+d*l
    if (S/=0) then
        Li=100.0*T/S
        if (S<=f .and. Li<=100.0*e/(100.0+e) .and. Li>noudo) then
          noudo=Li
          youeki=S
          yousitu=T
        endif
    endif
!    write(6,*) l
end do
end do
end do
end do

write(6,'(i0," "i0)') int(youeki),int(yousitu)
end 
