Go: package main

import (
	"fmt"
	"math"
)

func main(){
	var n, m, k int
	for {
		fmt.Scan(&n, &m, &k)
		if n == 0 && m == 0 && k == 0{
			break
		}

		dp := make([][]int, n+1)
		for i:= 0; i < n+1; i++{
			dp[i] = make([]int, m*n + 1)
		}

		for i := 1; i <=m ; i++{
			dp[1][i] = 1
		}

		for i:= 1; i < n; i++{
			for j := 0; j <= i * m; j++{
				for k := 1; k <= m; k++{
					dp[i+1][j+k] += dp[i][j]
				}
			}
		}

		count := 0.0
		div := math.Pow(float64(m), float64(n))
		for i := 0; i <= n * m; i++{
			bill := 0.0
			if i <= k{
				bill = 1.0
			} else {
				bill = float64(i - k)
			}
			count += bill * float64(dp[n][i]) / div
		}
		fmt.Printf("%.010f\n", count)
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    for (;;) {
        int n, m, k; cin >> n >> m >> k; if (!n) break;
        vector<double> p(n * m + 1, 0), p2(n * m + 1, 0);
        p[0] = 1.0;
        rep(i, 0, n) {
            rep(j, 1, m + 1) {
                for (int k = n * m - j; k >= 0; k--) {
                    p2[k + j] += p[k] / m;
                }
            }
            p = p2;
            p2 = vector<double>(n * m + 1, 0);
            // rep(j, 0, n * m + 1) printf("%.3lf ", p[i]);
            // printf("\n");
        }
        double v = 0;
        rep(i, 0, n * m + 1) {
            v += max(i - k, 1) * p[i];
        }
        cout << fixed << setprecision(12) << v << endl;
    }
}

C++: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	while (cin >> N >> M >> K, N) {
		long double ans = 0;
		vector<int>v(N, 1);
		while (v[0] <= M) {
			int add = accumulate(v.begin(), v.end(), 0) - K;
			ans += max(add, 1);
			int cnt = N - 1;
			v.back()++;
			while (cnt > 0 && v[cnt] > M) {
				v[cnt--] = 1;
				v[cnt]++;
			}
		}
		ans /= pow(M, N);
		cout << fixed << setprecision(20) << ans << endl;
	}
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const int MAX_SIZE=1000006;
int n,m,k;
double p[2][MAX_SIZE];
void solve() {
    rep(i,MAX_SIZE) p[0][i]=p[1][i]=0.0;

    rep(i,m) p[0][i+1]=1.0/m;
    rep(i,n-1) {
        rep(j,MAX_SIZE) {
            rep(k,m) {
                if(k+j+1>=MAX_SIZE) continue;
                p[1][k+j+1]+=p[0][j]/m;
            }
        }
        rep(j,MAX_SIZE) {
            p[0][j]=p[1][j];
            p[1][j]=0.0;
        }
    }
    double ans = 0.0;

    rep(i,m*n) {
        int b = max(1,i-k+1);
        //cout<<i+1<<" : "<<p[0][i+1]<<","<<b<<endl;
        ans += p[0][i+1]*b;
    }

    printf("%.8f\n",ans);
}

int main() {
    while(cin>>n>>m>>k) {
        if(n+m+k==0) break;
        solve();
    }
    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

long long dfs(long long N, long long M, long long K, long long d, long long sum) {
    if (d == N) return max(1LL, sum - K);
    long long ret = 0;
    for (long long i = 1; i <= M; i++) {
        ret += dfs(N, M, K, d + 1, sum + i);
    }
    return ret;
}

int main() {

    while (true) {

        long long N, M, K;
        cin >> N >> M >> K;

        if (!(N | M | K)) break;

        long long nomi = dfs(N, M, K, 0, 0);
        double deno = 1;
        for (int i = 0; i < N; i++) deno *= M;

        cout << fixed << setprecision(10) << (double) nomi / deno << endl;

    }

    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <iomanip>
#include <cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define erep(i, n) for (int i = 0; i <= n; i++)
#define orep(i, n) for (int i = 1; i <= n; i++)


double max(int i, int j)
{
	if (i > j) return (double)i;
	else return (double)j;
}

int main(void)
{
	while(1) {
		int n, m, k;
		cin >> n >> m >> k;
		if (n == 0 && m == 0) break;
		double dp[30][20000];
		memset(dp, 0, sizeof dp);
		//dp[サイコロの個数][目の合計]
		dp[0][0] = 1;
		rep(i, n) {
			erep(j, m * i) {
				orep(l, m) {
					dp[i + 1][j + l] += dp[i][j] / m;
				}
			}
		}

		double ans = 0;
		erep(i, m * n) ans += max(1, i - k) * dp[n][i];
		cout << fixed << setprecision(9) << ans << endl;
	}
	return 0;
}