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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using LL = long long;

int main(void)
{
	cout.precision(15);
	cout << fixed;
	for (;;)
	{
		int n, m, k;
		cin >> n >> m >> k;
		if (!n)break;
		//dp(i,j):=i??????m??¢???????????§j?????????????????°
		//dp[i][j] = dp[i-1][j-k](k=1~m)
		unordered_map<pair<int, int>, LL>dp;
		dp[{0, 0}] = 1;
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 0; j <= i * m; ++j)
			{
				for (int kk = 1; kk <= m; ++kk)
					dp[{i, j}] += dp[{i - 1, j - kk}];
			}
		}
		LL ans = 0;
		LL div = 0;
		for (int j = 0; j <= n * m; ++j)
		{
			int score = max(1, j - k);
			ans += dp[{n, j}] * score;
			div += dp[{n, j}];
		}
		cout << (double)ans / div << 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 = (double)((m - k) * (m - k + 1) / 2 + k) / pow(m, n);
    } else {
      for (int i = n; i <= n * m; i++) {
	if (i <= k) {
	  E += (double)comb(n, m, i) / pow(m, n);
	} else {
	  E += (double)comb(n, m, i) / pow(m, n) * (i - k);
	}
      }
    }
    printf("%l.8f\n", E);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

double dp[2][1000000];

int main() {
  int n, m, k;
  while (scanf("%d %d %d", &n, &m, &k), n|m|k) {
    //MEMSET(dp, 0);
    dp[0][0] = 1.0;
    REP(iter, n) {
      int prev = iter & 1;
      int next = (iter + 1) & 1;
      memset(dp[next], 0, sizeof(double) * (iter * m + m + 1));
      FOREQ(i, 0, iter * m) {
        FOREQ(j, 1, m) {
          dp[next][i + j] += dp[prev][i] / m;
        }
      }
    }
    double ans = 0;
    FOREQ(i, 1, n * m) {
      ans += max(i - k, 1) * dp[n & 1][i];
    }
    printf("%.7lf\n", ans);
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M,K;cin>>N>>M>>K;
        if(N+M+K==0) break;
        
        vector<vector<double>> dp(N+1,vector<double>(N*M+1));
        
        dp[0][0]=1.0;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<=i*M;j++){
                for(int k=1;k<=M;k++){
                    dp[i+1][j+k]+=dp[i][j]/M;
                }
            }
        }
        
        double ans=0.0;
        
        for(int j=0;j<=N*M;j++){
            if(j<=K) ans+=dp[N][j];
            else ans+=dp[N][j]*(j-K);
        }
        
        cout<<setprecision(25)<<ans<<endl;
    }
}

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

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){
    while(true){
        ll n,m,k;
        cin >> n >> m >> k;
        if(n == 0) break;
        vector<double> kak(n*m+1);
        kak[0] = 1;
        for(int i=0;i<n;i++){
            vector<double> next(n*m+1);
            for(int j=1;j<=m;j++){
                for(int l=0;l+j<n*m+1;l++){
                    next[l+j] += kak[l]/m;
                }
            }
            kak = next;
        }
        double ret = 0;
        for(int i=0;i<n*m+1;i++){
            ret += max(i-k,1ll)*kak[i];
        }
        cout << fixed << setprecision(8);
        cout << ret << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdio>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(a) a.begin(), a.end()

int main(){
	int n,m,k;
	while(cin>>n>>m>>k && n){
		map<int,double> cur;
		cur[0] = 1;
		rep(i,n){
			map<int,double> ne;
			for(auto &p:cur){
				for(int j=1;j<=m;j++){
					ne[p.first+j] += p.second/m;
				}
			}
			cur=ne;
		}
		double ans=0;
		for(auto &p:cur){
			ans += max(p.first-k, 1) * p.second;
		}
		printf("%.10lf\n", ans);
	}
}

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

int n, m, k;

int power(int m, int n) {
  int p = 1;
  for (int i = 0; i < n; i++) {
    p *= m;
  }
  return p;
}

int dfs(int depth, int sum) {
  if (depth == n) {
    return (sum - k > 0) ? sum - k : 1;
  }
  int res = 0;
  for (int i = 1; i <= m; i++) {
    res += dfs(depth + 1, sum + i);
  }
  return res;
}

int main() {
  while (true) {
    cin >> n >> m >> k;
    if (!n && !m && !k) return 0;
    int base = power(m, n);
    printf("%.8f\n", dfs(0, 0) / (double) base);
  }
}

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

#define int long long

int N, M, K;
int dp[50][100];

int dfs(int n, int sum) {
  if ( n == N ) return max(1LL, sum-K);
  if ( dp[n][sum] ) return dp[n][sum];

  int ret = 0;
  for ( int i = 1; i <= M; i++ ) ret += dfs(n+1, sum+i);

  return dp[n][sum] = ret;  
}
	
signed main() {
  cout << fixed << setprecision(10);
  
  while ( cin >> N >> M >> K, N ) {
    fill_n(*dp, 50*100, 0);    
    double ans = 0;
    ans = (double)dfs(0, 0);
    for ( int i = 0; i < N; i++ ) {
      ans /= M;      
    }

    cout << ans << endl;
  }

  return 0;
}