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("%15.10f\n", ans);
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int n, m, cut;
int cnt[10001];
void dfs(int sum,int loop) {
	if (loop == 0) {
		cnt[sum]++;
		return;
	}
	loop--;
	FOR(i, 1, m + 1) {
		dfs(sum + i, loop);
	}
}

int main() {
	while (cin>>n>>m>>cut,n) {
		REP(i, 10001)
			cnt[i] = 0;
		dfs(0,n);
		double ans = 0.0;
		REP(i, 10001) {
			ans += (double)max(i - cut, 1)*(double)cnt[i] / pow(m,n);
		}
		printf("%.8lf\n", ans);
	}
}

C++: #include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

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

        int N = pow(m, n);
        double a = 0;
        loop (N, I) {
            int i = I, sum = 0;
            loop (n, j) {
                sum += (i % m) + 1;
                i /= m;
            }
            sum = max(sum - k, 1);
            a += sum;
        }
        cout << setprecision(9) << fixed;
        cout << a / N << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
double n,m,k;
double p,b;
void saiki(int d,int v){
  if(d==n) {
    if(v>k)
      p+=v-k;
    else
      p++;
  }
  else{
    for(int i=1;i<=m;i++){
      saiki(d+1,v+i);
    }
  }
}
int main(){
  
  int i,j;
  cin >> n >> m >> k;
  while(n!=0){
    p=0;
    b=1;
    for(i=0;i<n;i++) b*=m;
    //cout << b << endl;
    saiki(0,0);
    //cout << p/b << endl;
    printf("%.8f\n",p/b);
    cin >> n >> m >> k;
  }


  return 0;
}

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

int N, M, K;
map<int, long long> cnt[2];

int main(){
	while(cin >> N >> M >> K, N){
		cnt[0].clear();
		cnt[0][0] = 1;
		for(int i = 0; i < N; i++){
			cnt[(i+1)%2].clear();
			for(auto e : cnt[i % 2]){
				for(int k = 1; k <= M; k++){
					cnt[(i+1)%2][e.first+k] += e.second;	
				}
			}
		}
		
		long long sum = 0;
		for(auto e : cnt[N%2]) sum += e.second;
		double ans = 0;
		for(auto e : cnt[N%2]){
			if(e.first <= K) ans += (double)e.second / sum; 
			else ans += (double)e.second * (e.first - K) / sum; 
		}
		printf("%.10lf\n", ans);

	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int n, m, k;
    while (cin >> n >> m >> k, n) {
        vector<vector<lli>> dp(n + 1, vector<lli>(n * m + 1, 0));
        dp[0][0] = 1LL;
        REP (i, 0, n) {
            REP (j, 0 * i, m * i + 1) {
                REP (t, 1, m + 1) {
                    dp[i + 1][j + t] += dp[i][j];
                }
            }
        }
        lli sum = 0;
        REP (i, 0, dp[n].size()) {
            int score = (i <= k ? 1 : i - k);
            sum += score * dp[n][i];
        }
        lli div = 1;
        REP (i, 0, n) div *= m;
        cout << fixed << setprecision(10) << (double) sum / div << endl;
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int prev[1000000];
int next[1000000];

int main(){
  int dice_num,side_num,cutback;
  
  while(~scanf("%d %d %d",&dice_num,&side_num,&cutback)){
    if(dice_num == 0) break;
    memset(prev,0,sizeof(prev));
    memset(next,0,sizeof(next));
    
    for(int i=1;i<=side_num;i++) prev[i] = 1;

    for(int i=1;i<dice_num;i++){
      for(int from=1;from<=side_num*dice_num;from++){
	for(int spots=1;spots<=side_num;spots++){
	  next[from+spots] += prev[from];
	}
      }
      memcpy(prev,next,sizeof(int)*1000000);
      memset(next,0,sizeof(next));
    }

    int sum = 0;
    for(int i=0;i<=side_num*dice_num;i++){
      sum += prev[i];
    }

    double exp = 0.0;
    for(int i=0;i<=side_num*dice_num;i++){
      double prob = (double)prev[i]/(double)sum;
      if(i-cutback <= 0){
	exp += 1.0 * prob;
      }
      else{
	exp += (double)(i-cutback) * prob;
      }
    }

    printf("%.8lf\n",exp);
  }
}