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 <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;


int dp[30][100010];

ll mod_pow(ll x, int n, int mod){
	if(n == 0) return 1LL;
	int ret = mod_pow(x*x % mod, n / 2, mod);
	if(n & 1) ret *= x;
	return ret % mod;
}

int main(){
	while(1){
		int n = in.nextInt(), m = in.nextInt(), K = in.nextInt();
		if(n == 0 && m == 0 && K == 0) break;
		for(int i = 0; i < 1e5 + 10; i++) for(int j = 0; j < 30; j++) dp[j][i] = 0;
		dp[0][0] = 1;
		for(int i = 1; i <= n; i++){
			for(int j = 0; j <= m*n; j++){
				for(int k = 1; k<= m; k++){
					dp[i][j+k] += dp[i-1][j];
				}
			}
		}
		double d = mod_pow(m, n, mod);
		//cout<<" "<<d<<endl;
		double ans = 0.0;
		for(int i = 0; i <= 1e5; i++) ans += max(1.0, (double)i-K) * dp[n][i] / d;
		
		printf("%.15lf\n", ans);
	}
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n,m,k;
  cin>>n>>m>>k;
  while(n!=0){
    vector<ll> dp((n+1)*(m+1));
    FOR(i,0,m){
      dp[i] = 1;
    }

    FOR(i,1,n){
      FORr(j,i*m-1,i-1){
        FOR(x,1,m+1){
          dp[j+x] += dp[j];
        }
        dp[j] = 0;
      }
    }
    ll sum = 0;
    FOR(i,0,n*m){
      ll mx = max((ll)0, i-k);
      sum += (mx+1)*(dp[i]);
    }
    ld div = pow(m,n);
    ld res = sum/div;
    cout(10)<<res<<endl;

    cin>>n>>m>>k;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};


int n,m,k;

void solve(){
  if(m==1){
    cout << max(1,n*m-k) << endl;
    return;
  }

  double dp[2][n*m+1];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  rep(i,n){
    int cu=i&1;
    int ne=(i+1)&1;
    memset(dp[ne],0,sizeof(dp[ne]));
    rep(j,m*(i+1)+1) if(dp[cu][j]) rep(k,m) dp[ne][j+k+1] += dp[cu][j]/m;
  }
  double ans=0;
  rep(j,n*m+1) ans += max(j-k,1)*dp[n&1][j];
  printf("%.8f\n",ans);
}

int main(int argc, char *argv[])
{
  while(cin >> n >> m >> k && n) solve();
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

int n, m, k;

template<class T>
T pow(T x, T n) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

ll dfs(int now_v,int cnt) {
	if (cnt == n) return max(now_v - k, 1);
	ll res = 0;
	REP(i, 1, m + 1) res += dfs(now_v + i, cnt + 1);
	return res;
}

signed main() {
	while (cin >> n >> m >> k) {
		if (n == 0) break;
		printf("%.20lf\n", (double)dfs(0, 0) / pow(m, n));
	}
	return 0;
}

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

int n,m,k;

int dfs(int sum,int num)
{
  if(num>=n){
    if(sum-k<1)return 1;
    return sum-k;
  }
  else {
    int ans=0;
    for(int i=1;i<=m;i++)ans+=dfs(sum+i,num+1);
    return ans;
  }
}

int main()
{
  while(1){
    cin>>n>>m>>k;
    if(n+m+k==0)break;
    
    printf("%.8f\n",dfs(0,0)/pow(m,n));
  }
  return 0;
}