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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
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 EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int 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);

int hist[2][500000];

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M, K;
  while(cin>>N>>M>>K,N){
	fill((int*)hist, (int*)hist+2*500000, 0);
	int crt=0, nxt=1;
	for(int i=1;i<=M;++i)
	  hist[crt][i] = 1;

	REP(i,N-1){
	  fill(hist[nxt], hist[nxt]+500000, 0);
	  REP(j,500000){
		if(hist[crt][j] == 0) continue;
		for(int k=1;k<=M;++k)
		  else hist[nxt][j+k] += hist[crt][j];
	  }
	  swap(crt, nxt);
	}

	double ans = 0., tot = pow(M, N);
	FOR(i,N,500000){
	  if(hist[crt][i] == 0) break;
	  if(i <= K)
		ans += hist[crt][i];
	  else
		ans += hist[crt][i] * (i - K);
	}
	cout << fixed << setprecision(8) << ans / tot << endl;
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
ll n,m;
vector<ll> numCombi(){
    vector<vector<ll>> ret(n+1,vector<ll>(n*m+2,0));
    ret[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n*m;j++){
            if(ret[i-1][j]!=0){
                ret[i][j+1]+=ret[i-1][j];
                ret[i][min(j+m,n*m)+1]-=ret[i-1][j];
            }
        }
        partial_sum(all(ret[i]),ret[i].begin());
        //for(auto j:ret[i])cout<<j<<", ";cout<<endl;
    }
    return ret[n];
}

ll factorial(int n){
    if(n==1)return 1;
    return n*factorial(n-1);
}

int main(){
    ll k;
    while(cin>>n>>m>>k,n){
        double ans=0;
        double total=pow(m,n);
        auto v=numCombi();
        for(int i=n;i<=k;i++){
            //cout<<i<<": "<<v[i]<<endl;
            ans+=v[i]/total;
        }
        for(int i=k+1;i<=n*m;i++){
            //cout<<i<<": "<<v[i]<<" * "<<i-p+1<<endl;
            ans+=v[i]/total*(i-k+2);
        }
        cout<<fixed<<setprecision(15)<<ans<<endl;
    }
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
typedef vector<vector<int> > VVI;
const int INF = 1e9;
const double EPS = 1e-6;

int sum;
int N, M, K;

void solve(int n, int s)
{
		if (n >= N) {
		sum += max(s-K, 1);
		return;
	}
	
	for (int i=1; i<=M; i++) {
		solve(n+1, s+i);
	}
}

int main()
{
	while (cin>>N>>M>>K, N) {
		sum = 0;
		solve(0, 0);
		cout << fixed << setprecision(8) << sum/pow(M, N) << endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	while(true){
		int n, m, k;
		cin >> n >> m >> k;
		if(n == 0 && m == 0 && k == 0){ break; }
		double answer = 0;
		if(n == 1){
			const double r = 1.0 / m;
			for(int i = 1; i <= m; ++i){
				answer += max(1, i - k) * r;
			}
		}else{
			const double r = 1.0 / m;
			const int len = n * m + 1;
			vector<double> dp(len);
			dp[0] = 1.0;
			for(int i = 0; i < n; ++i){
				vector<double> next(len);
				for(int j = 0; j + m < len; ++j){
					for(int k = 1; k <= m; ++k){
						next[j + k] += r * dp[j];
					}
				}
				dp.swap(next);
			}
			for(int i = n; i < len; ++i){
				answer += dp[i] * max(1, i - k); 
			}
		}
		cout << answer << endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, m, k;
		cin >> n >> m >> k;
		if (!n)break;
		vvi dp(n, vi(n*m, 0));
		REP(i, m)dp[0][i] = 1;
		REP(i, n - 1) {
			REP(j, n*m) {
				FOR(k, 1, m + 1) {
					if (j + k >= n*m)break;
					dp[i + 1][j + k] += dp[i][j];
				}
			}
		}


		long double sum = 0;
		REP(i, n*m) {
			if (i + 1 <= k)sum += dp[n - 1][i];
			else sum += (i + 1 - k)*dp[n - 1][i];
		}
		REP(i, n)sum /= m;
		cout << fixed << setprecision(12) << sum << endl;
	}
	return 0;
}