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 <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int n, m, k, x;
double ans;

void dfs(int node, int sum) {
    if (node == n) {
        if (sum-k < 1) sum = 1;
        else sum -= k;
        ans += (double)sum / x;
        return;
    }
    for (int i = 1; i < m+1; i++) {
        dfs(node+1, sum+i);
    }
    return;
}

int main(void){
    while (cin>>n>>m>>k && n) {
        ans = 0;
        x = pow(m,n);
        dfs(0, 0);
        printf("%.12lf\n",ans);
    }
}

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

using namespace std;

typedef long long ll;

ll n,m,k,sum;

void dfs(ll dep,double wa){
    for(int i=1;i<=m;i++){
        if(dep==n){
            if((wa+i-k)<1)sum+=1;
            else sum+=(wa+i-k);
        }
        else dfs(dep+1,wa+i);
    }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true){
      sum=0;
      cin>>n>>m>>k;
      if(n==0&&m==0&&k==0) break;
      dfs(1,0);
      double bunbo=1;
      for(int i=0;i<n;i++) bunbo*=m;
      //cout<<sum<<endl<<bunbo<<endl;
      cout<<fixed<<setprecision(10)<<sum/bunbo<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int n,m,k; 

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(cin >> n >> m >> k,n){
		double d=pow(m,n);
		printf("%.9f\n",dfs(n,0)/d);
	}
}

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

int main() {
    int n, m, k;
    while (cin >> n >> m >> k, n || m || k) {
        vector<map<int,int> > dp(n+1);
        dp[0][0] = 1;
        for (int i = 0; i < n; i++) {
            for (auto &j : dp[i]) {
                for (int l = 1; l <= m; l++) {
                    dp[i+1][j.first + l] += j.second;
                }
            }
        }

        int sum = 0;
        int count = 0;
        for (auto i : dp[n]) {
            if (i.first - k <= 1) count += i.second;
            else count += i.second * (i.first - k);
            sum += i.second;
        }

        printf("%.9f\n", (double)count/sum);
    }

    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	while(true){
		int n, m, k;
		cin >> n >> m >> k;
		if(n == 0 && m == 0 && k == 0){ break; }
		double answer = 0;
		if(n == 1){
			if(k == 0){ k = 1; }
			const double t = static_cast<double>(m - k + 1);
			const double r = t / m;
			answer += (t * (t + 1) * 0.5 / t) * r;
			answer += 1.0 - r;
		}else{
			const double r = 1.0 / m;
			const int len = n * m + 1;
			vector<double> dp(len);
			dp[0] = 1.0;
			for(int i = 0; i < n; ++i){
				vector<double> next(len + 1);
				for(int j = 0; j + m < len; ++j){
					next[j + 1] += r * dp[j];
					next[j + m + 1] -= r * dp[j];
				}
				double sum = 0.0;
				for(int j = 0; j <= len; ++j){
					sum += next[j];
					next[j] = sum;
				}
				dp.swap(next);
			}
			for(int i = n; i < len; ++i){
				answer += dp[i] * max(1, i - k); 
			}
		}
		cout << answer << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <math.h>

using namespace std;
int n, m, k;
double ans;

void DFS(vector<int> v)
{
	if(v.size() == n)
	{
		int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			sum += v[i];
		}
		ans += 1.0 * max(1, sum - k) / pow(1.0 * m, n);
		return;
	}
	for(int i = 1; i <= m; ++i)
	{
		v.push_back(i);
		DFS(v);
		v.pop_back();
	}
	return;
}

void solve()
{
	while(cin >> n >> m >> k, n || m || k)
	{
		ans = 0;
		vector<int> v;
		DFS(v);
		printf("%.8f\n", ans);
	}
}

int main()
{
	solve();
	return(0);
}

C++: //10
#include<iostream>
#include<algorithm>

using namespace std;

double dfs(int n,int m,int k,double p,int a){
  if(n==0){
    return max(a-k,1)*p;
  }else{
    double r=0;
    for(int i=1;i<=m;i++){
      r+=dfs(n-1,m,k,p/m,a+i);
    }
    return r;
  }
}

int main(){
  for(int n,m,k;cin>>n>>m>>k,n|m|k;){
    cout.precision(7);
    cout<<fixed<<dfs(n,m,k,1,0)<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
	int n, m, k;
	while (cin >> n >> m >> k && n){
		vector<vector<double> > dp(n+1, vector<double>(n*m+1));
		dp[0][0] = 1.0;
		REP(i,n) REP(j,(n-1)*m+1) FOR(p,1,m) {
			dp[i+1][j+p] += 1.0/m * dp[i][j];
		}
		double ans = 0.0;
		REP(i,m*n+1){
			if (i <= k) ans += dp[n][i];
			else ans += (i-k) * dp[n][i];
		}
		printf("%.10f\n", ans);
	}
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi
#define second se
using namespace std;
typedef pair<int, int> P;

int d[30][300010];

signed main(){
    int n, m, k;
    while(1){
        cin >> n >> m >> k;
        if(n + m + k == 0) break;
        rep(i, 0, 30) rep(j, 0, 300010) d[i][j] = 0;
        d[0][0] = 1;
        rep(i, 0, n){
            rep(j, i, 300000){
                if(d[i][j] == 0) break;                
                rep(l, 1, m + 1){
                    d[i + 1][j + l] += d[i][j];
                }
            }
        }
        double sum = 0;
        rep(i, 0, 300000){
            if(i <= k) sum += d[n][i];
            else sum += d[n][i] * (i - k);
        }
        rep(i, 0, n) sum /= (double)m;
        printf("%.14lf\n", sum);
    }
}