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;

#define int long long

int N, M, K;
int dp[33][65];

int dfs(int n, int sum) {
  if ( n == N ) return max(1LL, sum-K);
  if ( dp[n][sum] ) return dp[n][sum];

  int ret = 0;
  for ( int i = 1; i <= M; i++ ) ret += dfs(n+1, sum+i);

  return dp[n][sum] = ret;  
}
	
signed main() {
  cout << fixed << setprecision(10);
  
  while ( cin >> N >> M >> K, N ) {
    fill_n(*dp, 33*65, 0);    
    double ans = 0;
    ans = (double)dfs(0, 0);
    for ( int i = 0; i < N; i++ ) {
      ans /= M;      
    }

    cout << ans << endl;
  }

  return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    bool solve() {
        Int n, m, k;
        cin >> n >> m >> k;
        if (n == 0) return false;

        if (n == 1) {
            Double ans = (k + (1 + (m - k)) * (m - k) / 2.) / m;
            cout << ans << endl;
            return true;
        }

        vector<Double> kumi(static_cast<unsigned long>(n * m + 1));
        kumi[0] = 1.;
        rep(_, 0, n) {
            for (Int x = n * m; x >= 0; --x) {
                for (int y = 1; y <= m; ++y) {
                    if (x + y <= n * m)kumi[x + y] += kumi[x];
                }
                kumi[x] = 0.;
            }
        }

        Double ans = 0.0;
        for (Int x = 0; x <= n * m; ++x) {
            Double tmp = max<Double>(x - k, 1.) * kumi[x];
            ans += tmp;
        }
        for (int i = 0; i < n; ++i) {
            ans /= m;
        }
        cout << ans << endl;

        return true;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve());


    return 0;
}

C++: #include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n, m, k;
double mod;

double solve(int i, int sum)
{
	if (i == n)
	{
		if (sum <= k) return 1 / mod;
		return (sum-k) / mod;
	}
	double res = 0;
	FOR(j, 1, m + 1)
	{
		res += solve(i + 1, sum + j);
	}
	return res;
}
int main()
{
	while (cin >> n >> m >> k, n)
	{
		mod = pow(m, n);
		cout << D10 << solve(0, 0) << endl;
	}
	return 0;
}

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

// m<10^4 ？
// n<100  ？

int main(){
	int n,m,cut;
	while(cin>>n>>m>>cut && n&&m){
		vector<int> dp(n*m+1,0), tmp(n*m+1,0);
		dp[0]=1;


		for(int i=1; i<=n; i++){
			// サイコロ：i個

			for(int j=(i*m); j>=i; j--){
				// サイコロi個で出せる目の値：j

				for(int k=1; k<=m; k++){
					// サイコロの目：1~m
					// サイコロ1個抜いてみた値：(j-k)
					if(j-k>=0){
						// j-k が出せる
						// そうなら、当然 j も出せる
						tmp[j] += dp[j-k];
						// tmpに一時退避させておく
					}
				}
			}

			for(int j=0; j<=i*m; j++){
				// 一時退避させといたやつをdpに戻す
				dp[j]=tmp[j];
				tmp[j]=0;
			}
		}

		// dp[i] : n個のサイコロの目の合計値が(i)になる場合の数

		double under=0, over=0;
		for(int i=1; i<=n*m; i++){
			under += dp[i];
			over += dp[i] * max(i-cut,1);
		}

		printf("%.8lf\n",over/under);
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

int n, m, k;
vector<vector<double> > memo;

double dfs(int num = 0, int sum = 0) {
	if(num == n)
		return max(1, sum - k) * 1.0;

	if(memo[num][sum] >= 0.0)
		return memo[num][sum];

	double res = 0.0;
	for(int i = 1; i <= m; ++i)
		res += dfs(num + 1, sum + i) / m;

	return memo[num][sum] = res;
}

int main() {
	while(scanf("%d %d %d", &n, &m, &k), n) {
		memo.clear();
		memo.resize(n, vector<double>(n * m, -1.0));
		printf("%.10lf\n", dfs());
	}

	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

map< pair<int,int> ,double> dp;

int n,m,k;
double dfs(int sum,int n){
	if( dp.count({sum,n}) ) return dp[{sum,n}];
	if( sum < 0 ) return 0.0;
	if( sum == 0 ){	
		return n == 0 ? 1.0 : 0.0;
	}
	if( n <= 0 ) return 0.0;
	double res = 0;
	for(int i = 1 ; i <= m ; i++){
		res += dfs(sum-i,n-1) / m;
	}
	return dp[{sum,n}] = res;
}

int main(){
	while( cin >> n >> m >> k && n){
		dp.clear();
		double sum = 0;
		if( n == 1 ){
			for(int i = 1 ; i <= m ; i++)
				sum += (1./m) * max(1,(i-k));
		}else{
			for(int i = 1 ; i <= n * m ; i++){
				double p = dfs(i,n);
				sum += max(1,i-k) * p;
			}
		}
		printf("%.10lf\n",sum);
	}
}