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<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
int main() {
	int n, m, k;
	while (cin >> n >> m >> k, n) {
		if (n > 1) {
			double r = 1; double out = 0;
			rep(i, n) {
				r *= m;
			}
			ll cnt = 0; int dp[200] = {};
			dp[0] = 1;
			rep(i, n) {
				for (int j = 199; j >= 0; j--) {
					rep1(k, m) {
						if (j + k < 200) {
							dp[j + k] += dp[j];
						}
					}
					dp[j] = 0;
				}
			}
			rep(i, 200) {
				int x = i - k;
				if (x <= 0)x = 1;
				out += ((ll)dp[i] * (ll)x)/r;
			}
			cout << fixed << setprecision(8) << out << endl;
		}
		else {
			double out = 0;
			rep1(i, m) {
				int x = i - k;
				if (x <= 0)x = 1;
				out += x/(double)m;
			}
			cout << fixed << setprecision(8) << out << endl;
		}
	}
	return 0;
}

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

int n, m, k;

int dfs(int t, int sum) {
    if (t == n) {
        sum = max(1, sum-k);
        return sum;
    }
    int res = 0;
    for (int i=1; i<=m; ++i) {
        res += dfs(t+1, sum+i);
    }
    return res;
}

int main() {
    while (cin >> n >> m >> k) {
        if (!n) break;
        printf("%.8f\n", dfs(0, 0) / (double)pow(m, n));
    }
    return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b); }

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int N, M, K;
int cnt[1000];
int tmp[1000];

int main(){
	cout << setprecision(10) << fixed;
	while(cin >> N >> M >> K and N + M + K){
		memset(tmp, 0, sizeof(tmp));
		ld res = 0;
		if(N == 1){
			int s = 0;
			REP(i, M) s += max((i+1-K), 1);
			cout << s / (double) M << endl;
			continue;
		}
		REP(i, N){
			memset(cnt, 0, sizeof(cnt));
			if(i == 0) { REP(j, M) tmp[j] = 1; continue; }
			REP(j, M*(i+1)-i){
				if(j<M) REP(k, j+1) cnt[j] += tmp[k];
				else REP(k, M) cnt[j] += tmp[j-k];
			}
			REP(i, 1000) tmp[i] = cnt[i];
		}
		ld total = pow(M, N);
		REP(i, M*N) res += cnt[i] * max(N+i-K, 1) / total;
		cout << res << endl;
	}
	return 0;
}

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

using namespace std;

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

int n, m, k;

double solve(int sum, int n) {
  if (n == 0) {
    if (sum <= k) return 1;
    return sum - k;
  }
  double res = 0;
  rep(i, m) res += solve(sum + i + 1, n - 1);
  return res / m;
}

int main() {
  while (true) {
    cin >> n >> m >> k;
    if (n == 0 && m == 0 && k == 0) break;
    printf("%.12f\n", solve(0, n));
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <fstream>

using namespace std;

//#define REDFILE
#ifdef REDFILE
ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs
#endif

int n,m,k;
double dp[2][10001];
int main(){
    //FILE *fp=fopen("output.txt","w");
    FILE *fp=stdout;
    while(cin>>n>>m>>k&&!(n==0&&m==0&&k==0)){
        for(int i = 0; i < 10001; i++)dp[0][i]=dp[1][i]=0;
        dp[0][0]=1.0;
        for(int i = 0; i < n; i++){
            int nxt=(i+1)%2;
            int cnt=i%2;
            for(int i = 0; i < 10001; i++)dp[nxt][i]=0;
            for(int j = 1; j < 10001; j++){
                for(int k = 1; k <= m; k++){
                    if(j-k>=0)
                        dp[nxt][j]+=dp[cnt][j-k]*(1.0/m);
                    else break;
                }
            }
        }
        double res=0;
        for(int i = 0; i <= 10000; i++){
            int a=max(1,i-k);
            res+=a*(dp[n%2][i]);
        }
        //cout<<res<<endl;
        fprintf(fp,"%.8f\n",res);
    }

    return 0;
}

C++: #include <iostream>
#include <string>
#include <stdio.h>
#include <vector>

using namespace std;

#define eps 10e-9
#define max 105

int pow(int x,int n) {
	if( x == 0 ) return 0;
	if( n == 0 ) return 1;
	if( n == 1 ) return x;
	if( n & 1 ) {
		int y = pow( x, (n-1)/2 );
		return x * y * y;
	} else {
		int y = pow( x, n / 2 );
		return y * y;
	}
}

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1){
		int n, m, k;
		cin >> n >> m >> k;
		if( n == 0 && m == 0 && k == 0 ) break;

		double e = 0;
		int lim = pow(m, n);
		vector<int> fact;
		for(int i = 0; i <= n; i++) {
			fact.push_back(pow(m, i));
		}

		//m進数変換
		for(int i = 0; i < lim; i++) {
			int sum = 0;
			for(int j = 0; j < n; j++) {
				sum += ( ( i % fact[j+1] ) / fact[j] + 1);
			}
			sum -= k;
			if( sum <= 1 ) sum = 1;
			e += (double)(sum * 1.0) / (double) lim;
		}
		printf("%.8lf\n", e);
	}
	//swhile(1){}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int all;
double res;
int n, m, k;

void solve(int num, int sum) {
  if (num == n) {
    res += (double)max(sum-k, 1) / all;
    return;
  }
  REP(i, m) {
    solve(num+1, sum+i+1);
  }
}

int main() {
  while(cin>>n>>m>>k,n||m||k) {
    all = 1;
    REP(i, n) all*=m;
    res = 0;
    solve(0, 0);
    printf("%.12f\n", res);
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

map<int, int>mp;
int n, m, k;
void solve(int p, int s) {
	if (p == n) {
		mp[max(1, s - k)]++; return;
	}
	for (int i = 1; i <= m; i++)solve(p + 1, s + i);
}
int main() {
	while (scanf("%d%d%d", &n, &m, &k), n) {
		mp.clear(); solve(0, 0);
		int sum = 0;
		for (auto p : mp)sum += p.second;
		double ans = 0;
		for (auto p : mp)ans += p.first*p.second / (double)sum;
		printf("%.10lf\n", ans);
	}
}