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 <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

double dp[2][1000000];

int main() {
  int n, m, k;
  while (scanf("%d %d %d", &n, &m, &k), n|m|k) {
    MEMSET(dp, 0);
    dp[0][0] = 1.0;
    REP(iter, n) {
      int prev = iter & 1;
      int next = (iter + 1) & 1;
      MEMSET(dp[next], 0);
      FOREQ(i, 0, iter * m) {
        FOREQ(j, 1, m) {
          dp[next][i + j] += dp[prev][i] / m;
        }
      }
    }
    double ans = 0;
    FOREQ(i, 1, n * m) {
      ans += max(i - k, 1) * dp[n & 1][i];
    }
    printf("%.7lf\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;
    for (int i = n; i <= n * m; i++) {
      if (i <= k) {
	E += (double)comb(n, m, i) / pow(m, n);
      } else {
	E += (double)comb(n, m, i) / pow(m, n) * (i - k);
      }
    }
    printf("%l.10f\n", E);
  }
  return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
ll n, m, k;
map<ll, ll> MAP;
ll num;
void dfs(int cnt) {
  if(cnt == n) {
    MAP[max(1LL, num-k)]++;
  } else {
    FOR(i,1,m+1) {
      num += i;
      dfs(cnt+1);
      num -= i;
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin>>n>>m>>k,n||m||k) {
    num = 0;
    MAP.clear();
    ll waru = pow(m, n);
    dfs(0);
    double ans = 0;
    for(auto M : MAP) {
      ans += (double)M.first * M.second / waru;
    }
    printf("%.10lf\n", ans);
  }
  return 0;
}

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

using namespace std;

long long int pow(long long int m, long long int n){
	if(n == 1){
		return m;
	}
	return m * pow(m, n - 1);
}


long long int a[1000000];

int main(){
	
	long long int n, m, k;
	
	while(true){
		
		cin >> n >> m >> k;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < m * (n + 1); i++){
			a[i] = 0;
		}
		
		a[0] = 1;
		
		for(int loop = 0; loop < n; loop++){
			for(int i = m * n - 1; i >= 0; i--){
				for(int j = 1; j <= m; j++){
					a[i + j] += a[i];
				}
				a[i] = 0;
			}
		}
		
		long long int num = 0;
		
		for(long long int i = 1; i < m * (n + 1); i++){
			num += a[i] * max(1LL, i - k);
		}
		
		long long int den = pow(m, n);
		
		double ans = (double)num / (double)den;
		
		printf("%.8f\n", ans);
		
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m, x;
    while(cin >> n >> m >> x, n){
        vector<vector<double>> dp(2, vector<double>(n*m+1, 0));
        dp[0][0] = 1;
        for (int i = 0; i < n; ++i) {
            int now = i&1, nxt = now^1;
            fill(dp[nxt].begin(),dp[nxt].end(), 0);
            for (int j = 0; j <= m*i; ++j) {
                for (int k = 1; k <= m; ++k) {
                    dp[nxt][j+k] += dp[now][j]/m;
                }
            }
        }
        double ans = 0;
        for (int i = 0; i <= n*m; ++i) {
            ans += dp[n&1][i]*max(i-x, 1);
        }
        printf("%.8f\n", ans);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int n, m, k;
int cnt;

void dfs(int i, int sm) {
    if (i == n) {
        cnt += max(1LL, sm - k);
        return;
    }

    rep2(d, 1, m + 1) dfs(i + 1, sm + d);
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    while (cin >> n >> m >> k, n) {
        cnt = 0;
        dfs(0, 0);
        printf("%.10f\n", cnt / pow(m, n));
    }
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n, m, k; cin >> n >> m >> k;
		if (n == 0) break;
		int l = n * m;
		vector<double> dp(l + 1);
		dp[0] = 1;
		while (n--) {
			vector<double> imos(l + 1);
			for (int i = 0; i + 1 <= l; i++)
				imos[i + 1] += dp[i] / m;
			for (int i = 0; i + m + 1 <= l; i++)
				imos[i + m + 1] -= dp[i] / m;
			dp.assign(l + 1, 0);
			for (int i = 1; i <= l; i++)
				dp[i] = dp[i - 1] + imos[i];
		}
		double ans = 0;
		for (int i = 0; i <= l; i++)
			ans += dp[i] * max(1, i - k);
		printf("%.10f\n", ans);
	}
}