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;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const double INF=1e9;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int N,M,K;
double res;
void dfs(int cnt,int sum){
	if(cnt==N){
		res+=max(sum-K,1);
		return;
	}
	REP(i,M)dfs(cnt+1,sum+i+1);
}
int main(){
	
	while(cin>>N>>M>>K,N,M){
		res=0.0;
		dfs(0,0);
		double cmb=pow(M,N);
		cout<<fixed<<setprecision(10)<<res/cmb<<endl;
	}
	
	return 0;
}

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

long long int d[200000000] = {};

void kansu( long long int n, long long int m, long long int s ) {

  if ( n == 0 ) {

    d[ s ]++;
    return;

  }

  for ( long long int i = 1; i <= m; i++ ) {
    kansu( n - 1, m, s + i );
  }

  return;

}

int main() {

  while( true ) {

    long long int n, m, k;
    cin >> n >> m >> k;
    if ( n == 0 ) break;

    long long int a = 1;
    for ( long long int i = 0; i < n; i++ ) {
      a *= m;
    }

    long long int ans = 0;

    for ( long long int i = 0; i <= n * m; i++ ) {
      d[i] = 0;
    }

    kansu( n, m, 0 );

    for ( long long int i = 1; i <= n * m; i++ ) {

      ans += d[ i ] * max( 1LL, i - k );

    }

    cout << setprecision(10) << 1.00 * ans / a << endl;

  }

  return 0;

}

C++: #include<iostream>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;
typedef long long ll;

int main(){
    int n, m, k;
    while(cin >> n >> m >> k, n+m+k){
        vector<vector<double>> v(2, vector<double>(n*m+1, 0));
        for(int j = 0; j <= n*m; j++)   v[1][j] = 1.0;
        for(int i = 0; i < n; i++){
            v[i%2][0] = 0;
            for(int j = 1; j <= n*m; j++){
                v[i%2][j] = (v[(i+1)%2][j-1]-(j-1-m >= 0 ? v[(i+1)%2][j-1-m] : 0))/m;
                v[i%2][j] += v[i%2][j-1];
            }
        }
        double ans = 0;
        for(int j = 1; j <= n*m; j++)   ans += (v[(n+1)%2][j]-v[(n+1)%2][j-1]) * max(j-k, 1);
        cout << fixed << setprecision(12) << ans << endl;
    }
    return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

map<int,int> mp;
int n,m,k;

void dfs(int t, int sum){
    if(t==0){
        mp[max<int>(1,sum-k)]++;
        return ;
    }
    for(int i=1;i<=m;i++){
        dfs(t-1,sum+i);
    }
}

signed main(){
    while(cin>>n>>m>>k&&(n||m||k)){
        mp.clear();
        dfs(n,0);
        
        int ans = 0;
        for(auto elm:mp){
//            cout<<elm.first<<" "<<elm.second<<endl;
            ans += elm.first*elm.second;
        }
        printf("%.20lf\n",(double)ans/pow(m,n));
    }
}

C++: #include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;



int main(){
  int n, m, k;
  while(cin >> n >> m >> k && n + m + k > 0){
    double res = 0;

    vector<vector<double> > dp(n + 1,vector<double>(n * m + 1, 0.0)) ;    
    dp[0][0] = 1.0;
    
    REP(i, n){
      REP(j, n * m)REP(k, m){
        int nxt = j + k + 1;
        if(nxt <= n * m){
          // cout << nxt << endl;
          dp[i+1][nxt] += dp[i][j] / m;
        }
      }
    }
    
    for(int i = 0; i <= n * m; i++){
      res += dp[n][i] * max(1, i - k);
    }
    cout << fixed << setprecision(20) << res << endl;
  }
  return 0;
}

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 <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int ret;
int n, m, k;

void dfs(int freq, int num)
{
	if (freq == 0){
		ret += ((num - k) <= 0 ? 1 : num - k);
		// printf("%d %d -> %d\n", freq, num, ret);
		return;
	}
	else {
		for (int i = 1; i <= m; i++){
			dfs(freq-1, num + i);
		}
	}
	return;
}

int main(void)
{
	while (cin >> n >> m >> k, n && m){
		ret = 0;
		dfs(n, 0);

		printf("%.09lf\n", ret / pow((double)m, (double)n));
	}
}