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) {
    dp[0][0] = 1.0;
    REP(iter, n) {
      int prev = iter & 1;
      int next = (iter + 1) & 1;
      memset(dp[next], 0, sizeof(int) * (iter * m + m));
      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 <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF 1<<30
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int n, m, k;
ll dfs(int index, ll sum)
{
	if (index == n)
	{
		sum -= k;
		if (sum <= 0) sum = 1;
		return sum;
	}

	ll ret = 0;
	rep(i, 1, m + 1)
	{
		ret += dfs(index + 1, sum + i);
	}
	return ret;
}

int main()
{
	while (1)
	{
		cin >> n >> m >> k;
		if (n == 0) return 0;

		ll up = dfs(0, 0);
		ll down = 1;
		rep(i, 0, n) down *= m;
		double ans = (double)up / (double)down;
		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 = 1; 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 <stdio.h>
#include <algorithm>
#include <string.h>
#define REP(i,a,b) for (int i = (a); i < (b); i++)
#define rep(i,a) REP(i,0,a)

using namespace std;

int n,m,k;

int main(void){
    while (cin >> n >> m >> k && n) {
        int dp[n][n * m + 1];
        memset(dp,0,sizeof(dp));
        rep(i, m) dp[0][i + 1] = 1;
        REP(i, 1, n) rep(j, m*n+1) REP(k, max(0,j-m), j-1) dp[i][j] += dp[i-1][k];

        int s = 0;
        rep(i, m * n + 1) s += dp[n - 1][i];

        double ans = 0.0;
        rep(i, m * n + 1) ans += 1.0 * dp[n - 1][i] / s * max(1, i - k);
        printf("%.10f\n", ans);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
	for(int n,m,k;scanf("%d%d%d",&n,&m,&k),n|m|k;){
		double den=1;
		for(int i=0;i<n;i++) den*=m;
		ll p[10001]={1};
		for(int i=0;i<n;i++){
			ll t[10001]={};
			for(int j=1;j<=m;j++)
				for(int k=j;k<=10000;k++)
					t[k]+=p[k-j];
			memcpy(p,t,sizeof t);
		}
		
		double res=0;
		for(int i=0;i<=10000;i++)
			if(i<=k) res+=p[i]/den;
			else     res+=(i-k)*p[i]/den;
		printf("%.8f\n",res);
	}
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int n, m, s;
    while (cin >> n >> m >> s, n) {
        double dp[n+1][n*m+1];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        rep(i, n) {
            rep(j, n*m+1) {
                if (dp[i][j] > EPS) {
                    Rep(k, m+1) {
                        dp[i+1][j+k] += dp[i][j] / m;
                    }
                }
            }
        }
        double ans = 0;
        rep(i, n*m+1) {
            ans += dp[n][i] * ((i - s > 0) ? i-s : 1);
        }
        printf("%.10lf\n", ans);
    }

    return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;

double n, m, k;

double dfs(int num, int c){
    double sum=0;
    if(c==n) return (num-k)<=1 ? 1/pow(m, n) : (num-k)/pow(m, n);
    for(int i=1; i<=m; i++){
        sum+=dfs(i+num, c+1);
    }
    return sum;
}
int main(void){
    while(true){
        cin >> n >> m >> k;
        if(n+m+k==0) break;
        printf("%.8f\n", dfs(0, 0));
        
    }
    
    return 0;
}

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


double kuri2(double x,int a)
{
	double ret=1;
	double tmp=x;
	while(a!=0)
	{
		if(a&1)
			ret*=tmp;
		tmp=tmp*tmp;
		a>>=1;
	}
	return ret;
}
int saikoro[2][1000001];
int main()
{
	int n,m,k;
	while(1)
	{
		cin>>n>>m>>k;
		if(n==0)
			break;
		fill(saikoro[0],saikoro[2],0);
		saikoro[0][0]=1;
		//cerr<<"start"<<endl;
		for(int i=0;i<n;i++)
		{
			for(int l=0;l<i*m+1;l++)
			{
				if(saikoro[i&1][l]>0)
				{
					saikoro[(i+1)&1][l+1]+=saikoro[i&1][l];
					saikoro[(i+1)&1][l+m+1]-=saikoro[i&1][l];
				}
			}
			saikoro[i&1][0]=0;
			for(int j=1;j<1000001;j++)
			{
				saikoro[i&1][j]=0;
				saikoro[(i+1)&1][j]+=saikoro[(i+1)&1][j-1];
			}
		}
		double haha=kuri2(m,n);
		double ans=0;
		int cnt=0;;
		for(int i=0;i<1000001;i++)
		{
			if(saikoro[n&1][i]>0)
				ans+=(double)(max(i-k,1)*saikoro[n&1][i])/haha;
		}
		cout<<setprecision(12)<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,k;
double ans;
void saiki(int kai,int sum){
  if(kai == n) ans += max(1,sum-k);
  if(kai < n) {
  for(int i=1;i<=m;i++) {
    saiki(kai+1,sum+i);
  }
  }

}

int main() {

  while(1) {
    cin >> n >> m >> k;
    if(n==0 && m==0 && k==0) break;
    ans = 0;
    saiki(0,0);
    int t = 1;
    for(int i=0;i<n;i++) t*=m;
    printf("%.8f\n",ans/t);
    
  }

  return 0;
}