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;

int ipow(int x,int y) {
	if(y==1) return x;
	if(y&1) return x*ipow(x*x,y>>1);
	return ipow(x*x,y>>1);
}

int main() {
	int N,M,K;
	while(cin >> N >> M >> K,N) {
		vector<vector<int> > dp(N+1,vector<int>(N*M+1));
		dp[0][0]=1;
		for(int i=0;i<N;++i)
			for(int j=i;j<=i*M;++j)
				for(int k=1;k<=M;++k)
					dp[i+1][j+k]+=dp[i][j];
		int sum=0;
		for(int i=N;i<=N*M;++i) sum+=dp[N][i]*(i>K?i-K:1);
		printf("%.10f\n",sum/(double)ipow(M,N));
	}
	
	return 0;
}

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

#define N 1000000

using namespace std;

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

    int data[N];
    for(int i=0;i<=n*m;i++) data[i]=0;
    int num[15];
    for(int i=1;i<=n;i++) num[i]=1;
    bool end=false;
    for(;;){
      int sum=0;
      for(int i=1;i<=n;i++){
	//printf(" %d", num[i]);
	sum+=num[i];
      }
      //cout << endl;
      data[sum]++;
      if(num[n]==m){
	num[n]=0;
	for(int t=n-1;;){
	  if(t<=0){
	    end=true;
	    break;
	  }
	  if(num[t]<m){
	    num[t]++;
	    break;
	  }else{
	    num[t]=1;
	    t--;
	  }
	}
	if(end) break;
      }
      num[n]++;
    }
    double ans=0;
    for(int i=1;i<=k;i++){
      ans+=(double)data[i]/pow((double)m, (double)n);
    }
    for(int i=k+1, j=1;i<=n*m;i++, j++){
      ans+=(double)data[i]*j/pow((double)m, (double)n);
    }
    printf("%.10f\n", ans);
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int mmax=10010;
double dp[50][10010];


int main(void){
	int n,m,k;
	while(cin >> n >> m >> k){
		if(n==0)
			break;
		rep(i,50)rep(j,mmax) dp[i][j]=0.0;
		dp[0][0]=1.0;
		rep(i,n)rep(j,mmax){
			range(l,1,m+1)
				if(j+l<mmax)
					dp[i+1][j+l]+=1.0*dp[i][j]/m;
		}
		double ans=0.0;
		rep(j,mmax)
			ans+=(1.0*max(1,j-k)*dp[n][j]);
		cout.precision(9);
		cout << fixed << ans << endl;
	}
	return 0;
}

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

int sum[100000];
int n, m, k;

void solve(int i, int now) {
    if(i == n){
        sum[max(now-k, 1)]++;
        return;
    }
    for(int j=1;j<=m;j++){
        solve(i+1, now+j);
    }
}

int main() {
    while(true){
        cin >> n >> m >> k;
        if(n == 0) break;
        memset(sum, 0, sizeof(sum));
        solve(0, 0);
        double ans = 0;
        double sub = 1;
        for(int i=0;i<n;i++){
            sub *= m;
        }
        //cout << sub << endl;
        for(int i=0;i<=n*m;i++){
            //cout << sum[i] << " ";
            ans += (double)sum[i]*i/sub;
        }
        //cout << endl;
        printf("%.9lf\n", ans);
    }
    return 0;
}

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

int main(){
    for(ll n, m, k; cin >> n >> m >> k, n;){
        ll dp[n+1][n*m+1];
        for(ll i = 0; i <= n; i++){
            for(ll j = 0; j <= n * m; j++)dp[i][j] = 0;
        }
        dp[0][0] = 1;
        for(ll i = 0; i < n; i++){
            for(ll j = 0; j < n * m; j++){
                if(dp[i][j] == 0)continue;
                for(ll k = 1; k <= m; k++){
                    dp[i+1][j+k] += dp[i][j];
                }
            }
        }
        double a = 0, b = 0;
        for(ll i = 0; i <= n * m; i++){
            a += max(1LL, i - k) * dp[n][i];
            b += dp[n][i];
        }
        printf("%.9f\n", a / b);
    }
    return 0;
}