#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <int r>
struct Decimal{
    std::vector<int> digits;
    
    Decimal(int n) : digits(r + 1, 0) { // 1/n
        int rem = 1;
        for(int i=1;i<=r;++i){
            rem *= 10;
            digits[i] = rem / n;
            rem %= n;
        }
    }

    Decimal<r>& operator+=(Decimal<r> &rhs){
        for(int i=r;i>0;--i){
            digits[i] += rhs.digits[i];
            if(digits[i] >= 10){
                digits[i] -= 10;
                digits[i - 1] += 1;
            }
        }

        return *this;
    }
};

constexpr int r = 10100;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    while(true){
        int N, K, M, R;
        std::cin >> N >> K >> M >> R;

        if(N == 0){
            break;
        }

        Decimal<r> p(N);

        if(M == 1){
            for(int k=1;k<=N-1;++k){
                Decimal<r> d(k * N);
                p += d;
            }
        }

        std::cout << p.digits[0] << ".";
        for(int i=1;i<=R;++i){
            std::cout << p.digits[i];
        }
        std::cout << std::endl;
    }
}

