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>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m,k;
		cin>>n>>m>>k;
		if(n==0) break;
		vd a(m*n+1);
		a[0]=1;
		for(int i=0;i<n;i++){
			vd b(m*n+1);
			for(int j=0;j<=m*n;j++) if(a[j]>eps){
				for(int k=1;k<=m;k++) b[j+k]+=a[j]/m;
			}
			a=b;
		}
		double res=0;
		for(int i=0;i<=m*n;i++) res+=max(1,i-k)*a[i];
		cout<<syosu(9)<<res<<endl;
	}
}

C++: 
#include <iostream>
#include <vector>
#include <stdio.h>

int max( int p, int q ) {
	if( p > q ) return p;
	return q;
}

int pow(int x,int n) {
    if( x == 0 ) return 0;
    if( n == 0 ) return 1;
    if( n == 1 ) return x;
    if( n & 1 ) {
        int y = pow( x, (n-1)/2 );
        return x * y * y;
    } else {
        int y = pow( x, n / 2 );
        return y * y;
    }
}



int main( void ) {
	using namespace std;

	while( 1 ) {
		//n個のm面ダイス
		int n, m, k;
		cin >> n >> m >> k;
		if( n == 0 && m == 0 && k == 0 ) break;
		
		/*
			DPテーブルの作成
			dp[  ][ j ] = 合計がjになるパターンの個数
		*/
		vector< vector< int > > dp( 2, vector< int >( max( n * m + 1, 1 ), 0 ) ); 

		//初期化
		dp[ 0 ][ 0 ] = 1;

		//DP本体
		for( int i = 0; i < n; i++ ) {
			for( int j = 0; j < dp[0].size(); j++ ) {
				dp[ ( i + 1 ) % 2 ][ j ] = 0;
			}
			for( int j = 0; j < dp[0].size(); j++ ) {
				for( int k = 1; k <= m; k++ ) {
					if( k + j >= dp[0].size() ) break;
					dp[ ( i + 1 ) % 2 ][ k + j ] += dp[ i % 2 ][ j ];
				}
			}
		}
		int sum = 0;
		for( int i = 0; i < dp[0].size(); i++ ) {
			sum += max( 1, i - k ) * dp[ n % 2 ][ i ];
		}
		double e;
		e = ( double )( sum ) / pow( m, n );

		printf("%.8lf\n", e);
	}

	return 0;

}

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

using namespace std;

int n,m,k;
map<int,int> mp;
void loop(int sum, int l);

int main(int argc, char const *argv[])
{

	while(1){
		cin>>n>>m>>k;
		if(n+m+k==0) break;

		mp.clear();
		loop(0,1);

		int sum=0;
		for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
			sum+=((*it).first*(*it).second);
		}

		printf("%0.8f\n",sum/pow((double)m,(double)n));


	}
	return 0;
}

void loop(int sum,int l)
{
	for(int i1=1;i1<=m;i1++){
		if(l<n) loop(sum+i1,l+1);
		else {
			int temp=sum+i1-k;
			if(temp<=0) temp=1;
			mp[temp]++;
		}
	}
}

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

#define for_(i,a,b) for(int i=a;i<b;i++)
#define minit(a,b) memset(a,b,sizeof(a));

int n, m, k;

int dp[30][(int)1e5];

void solve() {
	minit(dp, 0);
	for_(p,1,m+1) dp[1][p] = 1;
	
	for_(i,1,n) {
		for_(j,1,n*m) {
			if (dp[i][j] == 0) continue;
			for_(p,1,m+1) if (j + p <= n*m) dp[i + 1][j + p] += dp[i][j];
		}
	}
	
	double ans = 0;
	double base = 1.0;
	for_(i,0,n) base *= m;
	for_(i,1,n*m+1) {
		int cnt = dp[n][i];
		if (i <= k) ans += (double)cnt / base;
		else ans += (double)(i - k) * (double)cnt / base;
	}
	
	printf("%.10lf\n", ans);
}

int main() {
	while (cin >> n >> m >> k, n) {
		solve();
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <memory.h>
#include <math.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//FILE *in = freopen("input.txt", "r", stdin);

int n, m, k;

int count[50000000];

void back(int lev, int sum) {
	if (lev == n) {
		count[sum]++;
		return;
	}
	rep(i, m) {
		back(lev+1, sum+i+1);
	}
}

void process() {
	long long sum = 0;
	long double q = pow((long double)m, n);
	memset(count, 0, sizeof(count));
	back(0, 0);
	for(int i = m*n; i > 0; i--) {
		int bills = i - k;
		if(bills < 1) bills = 1;
		sum += bills * count[i];
	}

	long double res = sum / q;
	printf("%.10Lf\n", res);
}

int main() {
	while(true) {
		scanf("%d%d%d", &n, &m, &k);
		if (!n) break;
		process();
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int n,m,k;
double ans;

void rec(int x,int sum){
  if(x==n){
    if(sum>k)ans+=(sum-k);
    else ans+=1.0;
  }else{
    for(int i=1;i<=m;i++){
      rec(x+1,sum+i);
    }
  }
}

int main(){
  while(1){
    cin>>n>>m>>k;
    if(n==0&&m==0&&k==0)break;
    if(n==1){
      double M=m,K=k;
      double a=(1.0+M-K)*0.5*(M-K);
      printf("%.8f\n",(a+K)/M);
    }else{
      ans=0;
      rec(0,0);
      double p=1.0;
      for(int i=0;i<n;i++)p*=m;
      printf("%.8f\n",ans/p);
    }
  }
  return 0;
}

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

int N, M, K;
map< pair< int, int >, long long > dp;
long long rec(int idx, int sum)
{
  if(idx == N) return(max(1, sum - K));
  if(dp.find({idx, sum}) != dp.end()) return(dp[{idx, sum}]);
  long long ret = 0;
  for(int i = 1; i <= M; i++) ret += rec(idx + 1, sum + i);
  return(dp[{idx, sum}] = ret);
}

int main()
{
  while(cin >> N >> M >> K, N) {
    dp.clear();
    long long ret = 0, power = 1;
    for(int i = 0; i < N; i++) power *= M;
    cout << fixed << 1.0 * rec(0, 0) / power << endl;
  }
}

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

#pragma warning(disable : 4996)

using namespace std;

int main()
{
	int n, m, c;

	while (true)
	{
		scanf("%d", &n);
		scanf("%d", &m);
		scanf("%d", &c);

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

		vector<vector<long double> > dp(n + 1, vector<long double>(n * m + 1, 0.0L));

		dp[0][0] = 1.0L;

		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n * m; j++)
			{
				for (int k = 1; k <= m && j - k >= 0; k++)
				{
					dp[i][j] += dp[i - 1][j - k] / m;
				}
			}
		}

		long double ret = 0.0L;

		for (int i = 0; i <= n * m; i++)
		{
			ret += dp[n][i] * (i - c < 1 ? 1 : i - c);
		}

		printf("%.20Lf\n", ret);
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
double dfs(int n, int m, int sum, int k){
  if (n == 0){
    return max(sum - k, 1);
  } else {
    double ans = 0;
    for (int i = 1; i <= m; i++){
      ans += dfs(n - 1, m, sum + i, k);
    }
    return ans / m;
  }
}
int main(){
  cout << fixed << setprecision(10);
  while (1){
    int n, m, k;
    cin >> n >> m >> k;
    if (n == 0 && m == 0 && k == 0){
      break;
    }
    cout << dfs(n, m, 0, k) << endl;
  }
}