#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 11000

int N,K,M,R;
int ans[NUM];

void calc(int bunshi,int bunbo){

	for(int i = 0; i < NUM; i++){
		ans[i] += bunshi/bunbo;
		bunshi %= bunbo;
		bunshi *= 10;
		if(bunshi == 0)return;
	}
}

void func(){

	for(int i = 0; i < NUM; i++)ans[i] = 0;

	if(M == 0){
		calc(1,N);
	}else{ //M == 1
		calc(1,N);
		for(int a = 1; a <= N-1; a++){
			calc(1,N*a);
		}
	}

	for(int a = NUM-1; a >= 1; a--){
		if(ans[a] >= 10){
			ans[a-1] += ans[a]/10;
			ans[a] %= 10;
		}
	}

	printf("%d.",ans[0]);
	for(int a = 1; a <= R; a++){
		printf("%d",ans[a]);
	}
	printf("\n");
}


int main(){

	while(true){
		scanf("%d %d %d %d",&N,&K,&M,&R);
		if(N == 0 && K == 0 && M == 0 && R == 0)break;

		func();
	}

	return 0;
}

