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;


#define rep(i,a) for(auto i=0;i<a;i++)
#define rbf(it,a) for(auto &it:a)

double f(int sum,int depth,int n,int m,int k,double nm){
	if(n==depth){

		//cout<<max(sum-k,1)<<" "<<nm<<endl;
		return(max(sum-k,1)/nm);
	}
	else{
		double res=0;
		rep(i,m){
			res+=f(sum+i+1,depth+1,n,m,k,nm);
		}
		return res;
	}

}

int main(){
	cout<<setprecision(8);
	cout<<fixed;
	while(true){
		int n,m,k;
		cin>>n>>m>>k;
		if((n|m|k)==0)break;

		double nm=1;
		{
			int t=n;
			double a=m;
			while(t){
				if(t&1)nm*=a;
				a=a*a;
				t>>=1;
		//		cout<<nm<<endl;
			}
		}
		cout<<f(0,0,n,m,k,nm)<<endl;


	}


	return 0;
}

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

using namespace std;

int n, m, k;

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

int main()
{
  while(cin >> n >> m >> k, n || m || k){
    printf("%.10f\n", dfs(0, 0)/pow(m, n));
  }
  return 0;
}

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

#define REP(i,N) for(int i = 0; i < (int)(N); ++i)
#define ALL(v) (v).begin(), (v).end()
typedef long long Int;
template<class T> void pv(T a, T b){for(T i=a;i!=b;++i)cout<<*i<<" ";cout<<endl;}

double dp[1024 * 1024];
double next[1024 * 1024];

double solve(int N, int M, int K) {
        if( N == 1 ) {
                double res = 0;
                for(int m = 1; m <= M; m++)
                        res += max(1, m - K);
                return res / M;
        }
        
        int L = N * M + 1;
        
        REP(i, L) dp[i] = 0;
        dp[0] = 1.0;
        double p = 1.0 / M;
        REP(step, N) {
                REP(i, L) next[i] = 0;
                REP(i, L) if( dp[i] > 0 ) 
                        for(int m = 1; m <= M; m++)
                                next[i + m] += dp[i] * p;
                REP(i, L) dp[i] = next[i];
        }
        double res = 0;
        REP(i, L) {
                res += max(1, i - K) * dp[i]; 
        }
        return res;
}

int main() {
        int N, M, K;
        for(;;) {
                cin >> N >> M >> K;
                if( N == 0 && M == 0 && K == 0 ) break;
                double res = solve(N, M, K);
                printf("%.8f\n", res);
        }
        return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    double x,y,z,p;
    double s;
    while(cin>>x>>y>>z){
            if(x==0 && y==0 && z==0){
                break;
            }

        p=x*y*z;

    s=(1/p + 2/p + 3/p) * 1 + 4/p * 2 + 5/p * 3 + 6/p * 4 + 5/p * 5 + 4/p * 6 + 3/p * 7 + 2/p * 8 + 1/p * 9;
    cout<<s<<endl;
    }

    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int N, M, K;

int dfs(int cur, vector<int> nums){
    if(cur == 0){
        int s = 0;
        for(int i=0; i<nums.size(); i++)
            s += nums[i];
        return s-K > 0 ? s-K: 1;
    }
    
    int ans = 0;
    nums.push_back(-1); //dummy;
    for(int i=1; i<=M; i++){
        nums[nums.size()-1] = i;
        ans += dfs(cur-1, nums);
    }
    return ans;
}

void solve(){
    double d = dfs(N, {});
    for(int i=0; i<N; i++)
        d /= M;
    printf("%.7lf\n", d);
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.precision(16);
    
    while(cin>>N>>M>>K, N|M|K)
        solve();
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int dp[2][100005];

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

		memset(dp, 0, sizeof(dp));
		REP(j, 1, m + 1) {
			dp[1][j] = 1;
		}

		rep(i, n) {
			rep(j, 100005) {
				if(dp[i & 1][j] == 0) continue;
				REP(k, 1, m+1) {
					dp[(i+1)&1][j+k] += dp[i&1][j];
				}
				dp[i&1][j] = 0;
			}
		}

		double ans = 0, t = 1;
		rep(i, n) {
			t *= m;
		}

		rep(j, 100005) {
			if(dp[n&1][j] == 0) continue;

			double l = j - k;
			if(l <= 0) l = 1;
			ans += (dp[n & 1][j] / t) * l;
		}

		cout << fixed;
		cout.precision(20);
		cout << ans << endl;
	}

	return 0;
}

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

int pow(int m, int n)
{
  if (n == 1) {
    return m;
  }
  if (n == 0) {
    return 1;
  }
  if (n % 2 == 0) {
    return pow(m, n / 2) * pow(m, n / 2);
  } else {
    return m * pow(m, n - 1);
  }
}

int comb(int n, int m, int k)
{
  if (n == 1) {
    if (1 <= k && k <= m) {return 1;}  
    else {return 0;}
  }
  if (k > m * n || k < n) {return 0;}
  
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    if (i >= k) {break;}
    sum += comb(n - 1, m, k - i);
  }
  return sum;
}

int main()
{
  int n, m, k;
  while (scanf("%d %d %d ", &n, &m, &k) == 3) {
    if (n == 0 && m == 0 && k == 0) {break;}
    double E = 0;
    if (n == 1) {      
      E = (m - k) * (m - k + 1) / 2 + k;
    } else {
      for (int i = n; i <= n * m; i++) {
	//printf("%d %d %d = %d\n", n, m, i, comb(n, m, i));
	if (i<= k) {
	  E += comb(n, m, i);
	} else {
	  E += comb(n, m, i) * (i - k);
	}
      }
    }
  printf("%l.8f\n", E / pow(m, n));
  }
  return 0;
}

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

int main()
{
  int n,m,k;
  while(scanf("%d%d%d", &n, &m, &k)){
    if(n==0&&m==0&&k==0)break;
    map<int,double> M;
    double res = 0;

    M[0] = 1;
    for(int i = 0; i < n; ++i){
      map<int,double> nM;
      for(int j = 1; j <= m; ++j){
	for(map<int,double>::iterator it = M.begin(); it != M.end(); ++it){
	  //double p = it->second * (1./m);
	  //if( nM.find(it->first+j)==nM.end() ){
	    nM[it->first+j] += it->second * (1./m);
	    //}
	}
      }
      M = nM;
    }

    for(map<int,double>::iterator it = M.begin(); it != M.end(); ++it){
      //cout << it->first << ' ' << it->second << endl;
      res += max(1,it->first-k) * it->second;
    }

    printf("%.12lf\n", res);
    //return 0;
  }
  return 0;
}