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 int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N,M,K;

int val;

void dfs(int n,int sum){
    if(n==N){
        if(sum>K)val+=sum-K;
        else val++;
        return;
    }
    reps(i,1,M+1)dfs(n+1,sum+i);
}

void solve(){
    if(M==1){
        if(N>K)printf("%.20f\n",1.0*N);
        else printf("%.20f\n",1.0);
        return;
    }
    val=0;
    dfs(0,0);
    int piyo=1;
    rep(i,N)piyo*=M;
    printf("%.20f\n",1.0*val/piyo);
}

signed main(){
    while(cin>>N>>M>>K,N||M||K)solve();
    return 0;
}

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("%l.10f\n", E);
  }
  return 0;
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

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

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,m,k;
double ans;
void dfs(vector<int> vec){
	if(vec.size()==n){
		int sum = 0;
		rep(i, n)sum +=vec[i];
		ans +=max(1,sum-k)/pow((double)m,(double)n);
		return;
	}
	repi(i, 1, m+1){
		vec.push_back(i);
		dfs(vec);
		vec.pop_back();
	}
	return ;
}


int main(){
	//double sum = 0;
	while(cin>>n>>m>>k,n||m||k){
	vector<int> v;
	v.clear();
	ans = 0;
	dfs(v);
	printf("%.8lf\n", ans);
	}
	return 0;
}

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

int main()
{
	while (true) {
		int n, m, k;

		cin >> n >> m >> k;

		if (n == 0 && m == 0 && k == 0) {
			break;
		}

		vector<vector<int>> dp(n + 1, vector<int>(n*m + 1, 0));
		dp[0][0] = 1;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= n*m; j++) {
				if (dp[i][j] == 0) {
					continue;
				}

				for (int l = 1; l <= m; l++) {
					if (j + l > n*m) {
						continue;
					}

					dp[i + 1][j + l] += dp[i][j];
				}
			}
		}

		int sum = 0;

		for (int i = 0; i <= n*m; i++) {
			sum += max(i - k, 1)*dp[n][i];
		}

		printf("%.8f\n", (double)sum / pow(m, n));

	}

	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    while(1){
        double n, m, k; cin >> n >> m >> k;
        if(n == 0.0) break;

        //dp[i][j] := i 番目までの賽を振って和が j になるときの確率
        vector<vector<double> > dp(n + 1, vector<double> (n * m + 1, 0.0));
        dp[0][0] = 1.0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= n*m; j++){
                if(dp[i][j] == 0.0) continue;

                for(int k = 1; k <= m; k++){
                    dp[i + 1][j + k] += dp[i][j] * 1.0 / m;

                }
            }
        }

        double ans = 0.0;
        for(int j = 1; j <= n * m; j++) ans += max(1.0, j - k) * dp[n][j];
        printf("%.10f\n", ans);
    
    }

    return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
int t[17][17];
int dp[64 * 1024];
int main() {
	int n, m, k;
	while (cin >> n >> m >> k, n) {
		vector<int> dice(n, 1);
		int sum = n;
		double e = 0;
		for (;;) {
			e += max(sum - k, 1);
			for (int i = 0; i < n; i++) {
				dice[i]++;
				sum++;
				if (dice[i] > m&&i!=n-1) {
					dice[i] = 1;
					sum -= m;
				}
				else break;
			}
			if (dice.back() > m)break;
		}
		cout << fixed << setprecision(10) << e / pow(m, n) << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n, m, k;
  while (cin >> n >> m >> k, n) {
    vector<vector<double>> dp(n + 1, vector<double>(n * m + 1, 0.));
    dp[0][0] = 1.;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= n * m; j++) {
        if (dp[i][j] == 0.) continue;
        for (int k = 1; k <= m && j + k <= n * m; k++) {
          dp[i + 1][j + k] += dp[i][j] * (1. / m);
        }
      }
    }
    
    double ans = 0.;
    for (int i = 0; i <= n * m; i++) {
      ans += dp[n][i] * max(1, i - k);
    }
    printf("%.10f\n", ans);
  }

  return 0;
}