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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using LL = long long;

int main(void)
{
	cout.precision(15);
	cout << fixed;
	for (;;)
	{
		int n, m, k;
		cin >> n >> m >> k;
		if (!n)break;
		//dp(i,j):=i??????m??¢???????????§j?????????????????°
		//dp[i][j] = dp[i-1][j-k](k=1~m)
		map<pair<int, int>, LL>dp;
		dp[{0, 0}] = 1;
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 0; j <= i * m; ++j)
			{
				for (int kk = 1; kk <= m; ++kk)
					dp[{i, j}] += dp[{i - 1, j - kk}];
			}
		}
		LL ans = 0;
		LL div = 0;
		for (int j = 0; j <= n * m; ++j)
		{
			int score = max(1, j - k);
			ans += dp[{n, j}] * score;
			div += dp[{n, j}];
		}
		cout << (double)ans / div << endl;
	}
	return 0;
}

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

using namespace std;
int n, m, k;
int ans = 0;

void dfs(int a, int b)
{
	if(a == 0)
	{
		ans += b - k <= 0 ? 1 : b - k;
		//cout << ans << endl;
	}
	else
	{
		for(int i = 1; i <= m; ++i)
		{
			dfs(a - 1, b + i);
		}
	}
}

void solve()
{
	while(cin >> n >> m >> k, n || m || k)
	{
		ans = 0;
		dfs(n, 0);
		printf("%.8f\n", ans / pow((double)m, n));
	}
}

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

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

int main(){
	int n, m, k;
	while( cin >> n >> m >> k , n || m || k ){
		int s = n * m;
		double dp[2][s+5];
		for(int i=0 ; i < s+5 ; i++ ){
			dp[0][i] = dp[1][i] = 0.0;
		}
		dp[0][0] = 1.0;
		for(int i = 0 ; i < n ; i++ ){
			for(int j = i ; j < s+5 ; j++ ){
				for(int k = 1 ; k < m+1 ; k++ ){
					if( s + 5 < j + k ) break;
					dp[1][j+k] += dp[0][j] * (1.0 / m);
				}
			}
			for(int j = i ; j < s+5 ; j++ ){
				dp[0][j] = dp[1][j];
				dp[1][j] = 0;
			}
		}
		double ans = 0.0;
		for(int i = 1 ; i < s+5 ; i++ ){
			if( i - k <= 1 ){
				ans += dp[0][i];
			}else{
				ans += dp[0][i] * (i - k);
			}
		}
		printf("%.8f\n", ans);
	}
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int pow(int m, int n)
{
  if (n == 1) {
    return m;
  }
  if (n == 0) {
    return 1;
  }
  if (n % 2 == 0) {
    return pow(m, n / 2) * pow(m, n / 2);
  } else {
    return m * pow(m, n - 1);
  }
}

int comb(int n, int m, int k)
{
  if (n == 1) {
    if (1 <= k && k <= m) {return 1;}  
    else {return 0;}
  }
  if (k > m * n || k < n) {return 0;}
  
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    if (i >= k) {break;}
    sum += comb(n - 1, m, k - i);
  }
  return sum;
}

int main()
{
  int n, m, k;
  while (scanf("%d %d %d ", &n, &m, &k) == 3) {
    if (n == 0 && m == 0 && k == 0) {break;}
    double E = 0;
    if (n == 1) {
      E = (double)((m - k) * (m - k + 1) / 2 + k);
    } else {
      for (int i = n; i <= n * m; i++) {
	//printf("%d %d %d = %d\n", n, m, i, comb(n, m, i));
	if (i<= k) {
	  E += (double)comb(n, m, i);
	} else {
	  E += (double)comb(n, m, i) * (i - k);
	}
      }
    }
  printf("%l.8f\n", E / pow(m, n));
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<cassert>
#include<map>
#define eps (1e-8)
#define MAX 100000
using namespace std;
int n,m,k;
int M[MAX];

void dfs(int a,int b,int cost)//a->n , b->m
{
  if(a >= n)
    {
      assert(cost < MAX);
      M[max(cost-k,1)]++;
      return;
    }

    for(int i=1;i<=m;i++)
    {
      dfs(a+1,b+i,cost+i);
    }

}

int main()
{
  while(cin >> n >> m >> k,n|m|k)
    {    
      for(int i=0;i<MAX;i++)M[i] = 0;     
      dfs(0,0,0);
      long double total = 0;
      for(int i=0;i<MAX;i++)total += i*M[i];
      cout << setiosflags(ios::fixed) << setprecision(8) << total/pow((double)m,(double)n) << endl;
    }
  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 <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#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 bfs(long long N, long long M, long long K, long long sum, long long count) {

    if (count == N) {
        return max(1LL, sum - K);
    }

    long long ret = 0;
    for (long long i = 1; i <= M; i++) {
        ret += bfs(N, M, K, sum + i, count + 1);
    }
    return ret;
}

int main() {

    while (true) {

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

        //n個
        //m面
        //-k
        if (!(N | M | K)) break;

        long long sum = bfs(N, M, K, 0, 0);
        long long denominator = 1LL;
        for (long long i = 1; i <= N; i++) denominator *= M;
        long double ans = (long double) sum / (long double) denominator;

        cout << fixed << setprecision(10) << ans << endl;

    }

    return 0;
}

C++: #include <cstdlib>
#include <iostream>
#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 <vector>
#include <algorithm>
using namespace std;

int main()
{
	while (true) {
		int n, m, k;

		cin >> n >> m >> k;

		if (n == 0 && m == 0 && k == 0) {
			break;
		}

		vector<vector<int>> dp(n + 1, vector<int>(n*m + 1, 0));
		dp[0][0] = 1;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= n*m; j++) {
				if (dp[i][j] == 0) {
					continue;
				}

				for (int l = 1; l <= m; l++) {
					if (j + l > n*m) {
						continue;
					}

					dp[i + 1][j + l] += dp[i][j];
				}
			}
		}

		int sum = 0;

		for (int i = 0; i <= n*m; i++) {
			sum += max(i - k, 1)*dp[n][i];
		}

		cout << (double)sum / pow(m, n) << endl;
	}

	return 0;
}