#include <vector>
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
int n, m, r, q = 5;
int main() {
	while (scanf("%d%*d%d%d", &n, &m, &r), n) {
		vector<int> sum(r + q + 1, 0);
		vector<int> w; w.push_back(n);
		if (m == 1) for (int i = 1; i < n; i++) w.push_back(n * i);
		for (int i : w) {
			vector<int> p(r + q + 2, 0);
			int z = 1;
			for (int j = 0; j <= r + q + 1; j++) {
				p[j] = z / i;
				z = z % i * 10;
			}
			if (p[r + q + 1] >= 5) {
				for (int j = r + q; j >= 0; j--) {
					p[j] += 1;
					if (p[j] >= 10) p[j] -= 10;
					else break;
				}
			}
			for (int j = r + q; j >= 0; j--) {
				sum[j] += p[j];
				if (sum[j] >= 10) sum[j] -= 10, sum[j - 1]++;
			}
		}
		cout << sum[0] << '.';
		for (int i = 1; i <= r; i++) cout << sum[i];
		cout << endl;
	}
	return 0;
}