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)
		  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;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m,k;
int cnt[11111111];

void dfs(int sum,int num){
	if(num==n){
		cnt[sum]++;
		return;
	}
	repl(i,1,m+1){
		dfs(sum+i,num+1);
	}
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m>>k;
		if(n==0)break;
		memset(cnt,0,sizeof(cnt));
		dfs(0,0);
		double res=0;
		repl(i,n,n*m+1){
			if(i>k){
				res+=(double)((i-k)*cnt[i])/pow(m,n);
			}else{
				res+=(double)(1.0*cnt[i])/pow(m,n);
			}
		}
		printf("%.10f\n", res);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> pii;

double ans;
int N,M,K;

void dfs(int t,int res){
	if(t==N){
		if(res<=K)ans+=1;
		else ans +=res-K;
	}
	else{
		FOR(j,1,M+1){
			dfs(t+1,res+j);
		}
	}
}

void solve(){
	ans = 0;
	cin>>N>>M>>K;
	if(N==0)exit(0);
	dfs(0,0);
	REP(_,N){
		ans/=M;
	}
	printf("%.10lf\n",ans);
}

signed main() {
	while (true) {
		solve();
	}
}

C++: #include<cstdio>
#include<algorithm>

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

using namespace std;

typedef	long long	ll;

int main(){
	for(int m,n,cut;scanf("%d%d%d",&n,&m,&cut),n;){
		static ll dp[30][300010];
		rep(i,n)rep(j,m*n+1)	dp[i][j]=0;
		rep(i,n){
			for(int j=i+1;j<=m*(i+1);j++){
				if(i==0)	dp[i][j]=1;
				else{
					for(int k=1;k<=m;k++){
						if(j-k>=1)	dp[i][j]+=dp[i-1][j-k];
					}
				}
			}
		}

		ll nu=0,de=1;
		rep(j,m*n+1)	nu+=max(1,j-cut)*dp[n-1][j];
		rep(i,n)		de*=m;
		printf("%.9f\n",(double)nu/de);
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,m,k;
long double p;
void dfs(int d,int x){
  if(d==0)
    if(x-k<=0)p+=1;
    else p+=x-k;
  else
    for(int i=1;i<=m;i++)
      dfs(d-1,x+i);
}
int main(){
  while(cin>>n>>m>>k,n){
    p=0;dfs(n,0);
    printf("%.8f\n",(long double)(p/(pow(m,n))));
  }
}

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

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

        vector<double> prob(n*m+1, 0.0);
        prob[0] = 1.0;
        for(int i=0; i<n; i++){
            vector<double> next(m*(i+1)+1, 0.0);
            for(int j=i; j<=m*(i+1); j++){
                for(int d=1; d<=m; d++){
                    next[j+d] += prob[j]/m;
                }
            }
            for(int j=i; j<=m*(i+1); j++){
                prob[j] = next[j];
            }
        }

        double exp = 0.0;
        for(int i=0; i<=n*m; i++){
            exp += prob[i] *max(i-k, 1);
        }
        cout << fixed;
        cout << setprecision(10);
        cout << exp << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

unordered_map<int, int>mp;
int n, m, k;
void solve(int p, int s) {
	if (p == n) {
		mp[max(1, s - k)]++; return;
	}
	for (int i = 1; i <= m; i++)solve(p + 1, s + i);
}
int main() {
	while (scanf("%d%d%d", &n, &m, &k), n) {
		mp.clear(); solve(0, 0);
		int sum = 0;
		for (auto p : mp)sum += p.second;
		double ans = 0;
		for (auto p : mp)ans += p.first*p.second / (double)sum;
		printf("%.10lf\n", ans);
	}
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>

int n,m,k;
double all;
void dfs(int v,int val){
	if(v==n){
		all+=std::max(val-k,1);
		return;
	}
	for(int i=1;i<=m;i++){
		dfs(v+1,val+i);
	}
}

int main(void){
	while(1){
		scanf("%d %d %d",&n,&m,&k);
		if(n+m+k==0)break;
		all=0.0;
		dfs(0,0);
		for(int i=0;i<n;i++){
			all/=m;
		}
		printf("%.20f\n",all);
	}
	return 0;
}