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 <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

int main(){
	//freopen("test.txt", "r", stdin);

	cout.setf(ios::fixed);
	cout.precision(8);

	int n, m, k;
	while(cin >> n >> m >> k, n|m|k){
		int size = n*m+1;
		vector<vi> v(2, vi(size, 0));
		v[0][0] = 1;
		int next = 1;
		rep(j, n){
			v[next] = vi(size, 0);
			for(int k = j; k <= j*m; k++){
				if(v[!next][k] == 0)continue;
				for(int i = 1; i <= m; i++){
					v[next][k+i] += v[!next][k];
				}
			}
			next = !next;
		}

		double ans = 0;
		double d = pow((double)m, n);

		for(int i = n; i < size; i++){
//			printf("%d/%d*%d+", v[!next][i], (int)d, max(i-k, 1));
			ans += v[!next][i]*(max(i-k, 1))/d;
		}

		cout << ans << endl;

	}

	return 0;
}

C++: #include<iostream>
#include<iomanip>
using namespace std;
int n,m,k;
int dp[32][1<<20];
main()
{
	while(cin>>n>>m>>k,n)
	{
		for(int i=0;i<=n;i++)for(int j=0;j<=n*m;j++)dp[i][j]=0;
		dp[0][0]=1;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<=n*m;j++)
			{
				for(int k=0;k<m;k++)dp[i+1][j+k+1]+=dp[i][j];
			}
		}
		double ans=0;
		for(int i=0;i<=n*m;i++)ans+=1L*dp[n][i]*(i>k?i-k:1);
		for(int i=0;i<n;i++)ans=ans/m;
		cout<<fixed<<setprecision(9)<<ans<<endl;
	}
}

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;

int N, M, K;
map< pair< int, int >, long long > dp;
long long rec(int idx, int sum)
{
  if(idx == N) return(max(1, sum - K));
  if(dp.find({idx, sum}) != dp.end()) return(dp[{idx, sum}]);
  long long ret = 0;
  for(int i = 1; i <= M; i++) ret += rec(idx + 1, sum + i);
  return(dp[{idx, sum}] = ret);
}

int main()
{
  while(cin >> N >> M >> K, N) {
    dp.clear();
    long long ret = 0, power = 1;
    for(int i = 0; i < N; i++) power *= M;
    cout << fixed << setprecision(10) << 1.0 * rec(0, 0) / power << endl;
  }
}

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

int main(){
    int n,m,k;
    while(cin>>n>>m>>k,n){
        vector<vector<long long int>> dp(n+1,vector<long long int>(m*n+1,0));
        dp[0][0]=1;
        long long int sum=1;
        for(int i=1;i<=n;i++){
            sum*=m;
            for(int j=0;j<=m*n;j++){
                for(int s=1;s<=m;s++){
                    if(j-s>=0) dp[i][j]+=dp[i-1][j-s];
                }
            }
        }

        double res=0.0;
        for(int i=1;i<=n*m;i++){
            res+=double(i<=k ? 1 : i-k)*double(dp[n][i])/double(sum);
        }
        cout<<setprecision(10)<<fixed;
        cout<<res<<endl;
    }


}

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

using namespace std;
int n, m, k;
double ans;

void DFS(vector<int> v)
{
	if(v.size() == n)
	{
		int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			sum += v[i];
		}
		ans += 1.0 * max(1, sum - k) / pow(1.0 * m, n);
		return;
	}
	for(int i = 1; i <= m; ++i)
	{
		v.push_back(i);
		DFS(v);
		v.pop_back();
	}
	return;
}

void solve()
{
	while(cin >> n >> m >> k, n || m || k)
	{
		ans = 0;
		vector<int> v;
		DFS(v);
		printf("%.8f\n", ans);
	}
}

int main()
{
	solve();
	return(0);
}