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++: #define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n, m, k;
		cin >> n >> m >> k;
		if (n == 0) return;
		long double dp[30001] = {};
		dp[0] = 1;
		REP(i, n) {
			for (int q = 30000; q >= 0; --q) {
				if (dp[q] == 0.00000000000000L) {
					continue;
				}
				long double prob = dp[q] / (long double)m;
				for (int j = 1; j + q <= 30000 && j <= m; ++j) {
					dp[q + j] += prob;
				}
				dp[q] = 0;
			}
		}
		long double ans = 0;
		for (int i = 0; i <= 30000; ++i) {
			long double cnt = max(1LL, i - k);
			ans += dp[i] * cnt;
		}
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N,M,K;



ll dfs(int n, int s){
  if(n==N) return max(1, s);
  ll res = 0;
  for(int i=1;i<=M;i++){
    res += dfs(n+1, s+i);
  }
  return res;
}

int main(){
  while(cin >> N >> M >> K && N+M+K){
    cout << fixed << setprecision(12) << dfs(0, -K)/(double)pow(M, N) << endl;
  }
  return 0;
}

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

int Pow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) {
			res *= a;
		}
		a *= a;
		b >>= 1;
	}
	return res;
}

int main()
{
	cout << fixed << setprecision(8) << endl;
	int n, m, k;
	while (cin >> n >> m >> k, n | m | k) {
		vector<vector<int>> dp(n + 1, vector<int>(n * m + 1));
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = i - 1; j <= m * (i - 1); j++) {
				for (int k = 1; k <= m; k++) {
					dp[i][j + k] += dp[i - 1][j];
				}
			}
		}
		ld res = 0;
		for (int i = 0; i <= n * m; i++) {
			res += dp[n][i] * max(1, i - k) / (ld)Pow(m, n);
		}
		cout << res << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    while(true) {
        int N, M, K;
        cin >> N >> M >> K;
        if(!N && !M && !K) break;

        int patnum = 1;
        for(int i = 0; i < N; ++i) patnum *= M;

        int sum = 0;
        for(int i = 0; i < patnum; ++i) {
            int pat = i;
            int dice = 0;
            for(int j = 0; j < N; ++j) {
                int n = (pat % M) + 1;
                dice += n;
                pat /= M;
            }
            if(dice > K) sum += dice - K;
            else sum += 1;
        }

        printf("%.8f\n", (double)sum / patnum);
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
 
using namespace std;
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007
 
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
 
int N,M,K;
 
 
 
ll dfs(int n, int s){
  if(n==N) return max(1, s);
  ll res = 0;
  for(int i=1;i<=M;i++){
    res += dfs(n+1, s+i);
  }
  return res;
}
 
int main(){
  while(cin >> N >> M >> K && N+M+K){
    cout << fixed << setprecision(12) << dfs(0, -K)/(double)pow(M, N) << endl;
  }
  return 0;
}

C++: #include <fstream>
#include <vector>

using namespace std;

int main(){
	int n, m ,k;
	while(cin >> n >> m >> k, n){
		vector<double> cur(n*m+1, 0.0);
		cur[0] = 1.0;
		for(int i=0;i<n;i++){
			vector<double> next(n*m+1, 0.0);
			for(int j=0;j+m<=n*m;j++)
				for(int l=1;l<=m;l++)
					next[j+l] += cur[j]/m;
			cur = next;
		}
		double ans = 0.0;
		for(int i=1;i<=n*m;i++)
			ans += cur[i]*max(1,i-k);
		printf("%.8lf\n", ans);
	}
}

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=100005;
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;
}