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 <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int n, m, k;
	while(1){
		cin >> n >> m >> k;
		if(n == 0 && m == 0 && k == 0) break;
		double result[n * m + 1][n + 1];
		for(int i = 0; i < n * m + 1; i++){
			for(int j = 0; j < n + 1; j++){
				result[i][j] = 0.0;
			}
		}
		for(int i = 1; i < m + 1; i++){
			result[i][1] = (double)1 / m;
		}
		for(int i = 2; i < n + 1; i++){
			for(int j = 1; j < m * (i - 1) + 1; j++){
				for(int k = 1; k < m + 1; k++){
					result[j + k][i] += (double)result[j][i - 1] / m;
				}
			}
		}
		double ans = 0;
		for(int i = 1; i < n * m + 1; i++){
			if(i > k){
				ans += (i - k) * result[i][n];
			} else {
				ans += result[i][n];
			}
		}
		printf("%8f\n", ans);
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>

#define N 100000001

using namespace std;

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

    int data[N];
    for(int i=0;i<=n*m;i++) data[i]=0;
    int num[15];
    for(int i=1;i<=n;i++) num[i]=1;
    bool end=false;
    for(;;){
      int sum=0;
      for(int i=1;i<=n;i++){
	//printf(" %d", num[i]);
	sum+=num[i];
      }
      //cout << endl;
      data[sum]++;
      if(num[n]==m){
	num[n]=0;
	for(int t=n-1;;){
	  if(t<=0){
	    end=true;
	    break;
	  }
	  if(num[t]<m){
	    num[t]++;
	    break;
	  }else{
	    num[t]=1;
	    t--;
	  }
	}
	if(end) break;
      }
      num[n]++;
    }
    double ans=0;
    for(int i=1;i<=k;i++){
      ans+=(double)data[i]/pow((double)m, (double)n);
    }
    for(int i=k+1, j=1;i<=n*m;i++, j++){
      ans+=(double)data[i]*j/pow((double)m, (double)n);
    }
    printf("%.10f\n", ans);
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <stdio.h>
#include <vector>

using namespace std;

#define eps 10e-9

int pow(int x,int n) {
	if( x == 0 ) return 0;
	if( n == 0 ) return 1;
	if( n == 1 ) return x;
	if( n & 1 ) {
		int y = pow( x, (n-1)/2 );
		return x * y * y;
	} else {
		int y = pow( x, n / 2 );
		return y * y;
	}
}

int main(void){

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

		double e = 0;
		int lim = pow(m, n);
		vector<int> fact;
		for(int i = 0; i <= n; i++) {
			fact.push_back(pow(m, i));
		}

		//m進数変換
		for(int i = 0; i < lim; i++) {
			int sum = 0;
			for(int j = 0; j < n; j++) {
				sum += ( ( i % fact[j+1] ) / fact[j] + 1);
			}
			sum -= k;
			if( sum <= 1 ) sum = 1;
			e += (double)(sum * 1.0) / (double) lim;
		}
		printf("%.8lf\n", e);
	}
	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n, m, k;
double res, oc;

void dfs(int, int);

int main(void){
    for(; cin >> n >> m >> k, n; printf("%.8f\n", res)){
        res = 0.;
        oc = pow((double)m, (double)n);
        dfs(0, 0);
    }

	return 0;
}

void dfs(int nn, int sum){
    if(nn == n){
        res += max(1, sum - k) / oc;
        return;
    }

    range(i, 1, m + 1){
        dfs(nn + 1, sum + i);
    }
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    ll n, m, k;
    while(cin>>n>>m>>k, n){
        vector<vector<ll>> dp(n+10, vector<ll>(n*m+10, 0));
        dp[0][0]=1;
        for(int i=0; i<n; i++){
            for(int sum=0; sum<=n*m; sum++){
                for(int side=1; side<=m; side++){
                    if(sum+side>n*m) continue;
                    dp[i+1][sum+side]+=dp[i][sum];
                }
            }
        }

        double div=1;
        for(int i=0; i<n; i++) div/=m;

        double ans=0;
        for(ll i=0; i<=n*m; i++){
            if(i<=k) ans+=1.*dp[n][i]*div;
            else ans+=1.*dp[n][i]*div*(i-k);
            //cout << i << " " << dp[n][i] << endl;
        }
        cout << fixed << setprecision(10) << ans << endl;
    }
}

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

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;
    for (int i = n; i <= n * m; i++) {
      if (i <= k) {
	E += (double)comb(n, m, i) / pow((double)m, n);
      } else {
	E += (double)comb(n, m, i) / pow((double)m, n) * (i - k);
      }
    }
    printf("%lf\n", E);
  }
  return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;i++)
#define minit(a,b) memset(a,b,sizeof(a));

int n, m, k;

int dp[30][(int)1e5];

void solve() {
	minit(dp, 0);
	dp[0][0] = 1;
	
	for_(i,0,n) {
		for_(j,0,n*m) {
			if (dp[i][j] == 0) continue;
			for_(p,1,m+1) if (j + p <= n*m) dp[i + 1][j + p] += dp[i][j];
		}
	}
	
	double ans = 0;
	double base = 1.0;
	for_(i,0,n) base *= m;
	for_(i,1,n*m+1) {
		int cnt = dp[n][i];
		if (i <= k) ans += (double)cnt / base;
		else ans += (double)(i - k) * (double)cnt / base;
	}
	printf("%lf\n", ans);
}

int main() {
	while (cin >> n >> m >> k, n) {
		solve();
	}
	
	return 0;
}