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<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int n, m, k, dp[100000];
void dfs(int cnt, int sum) {
	//cout << cnt << " " << sum << endl;
	if(cnt == 0) {
		dp[max(sum-k, 1)]++;
		return;
	}
	FOR(i, 1, m+1) {
		dfs(cnt-1, sum+i);
	}
}

signed main(void)
{
	while(true) {
		cin >> n >> m >> k;
		if(!n && !m && !k) break;
		REP(i, 100000) dp[i] = 0;
		dfs(n, 0);
		double sum = 0;
		REP(i, 100000) sum += i*dp[i];
		REP(i, n) sum /= m;
		cout << fixed << setprecision(15) << sum << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int beki(int a, int n){
    int ret = 1;
    rep(i,n)ret *= a;
    return ret;
}
int main(void) {
    int i,j;
    int n,m,k;
    while(cin >> n >> m >> k, n){
        double ans = 0;
        int sum = beki(m,n);
        rep(i,sum){
            int s = 0;
            int t = i;
            rep(i,n){
                s += t % m + 1;
                t /= m;
            }
            s = max(s-k, 1);
            ans += 1.0*s/sum;
        }
        cout << shosu(10) << ans << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int n, m, k;
    while(cin >>n >>m >>k && (n || m || k)){
        int s = m * n;
        vector< vector<double> > dp(2, vector<double>(s + 5, 0));
        dp[0][0] = 1.0;

        REP(i, n){
            FOR(j, s + 5, i){
                FOR(k, m + 1, 1){
                    if(j + k > s + 5) break;
                    dp[1][j + k] += (dp[0][j] * (1.0 / m) * 1.0);
                }
            }
            FOR(j, s + 5, i){
                dp[0][j] = dp[1][j];
                dp[1][j] = 0;
            }
        }
        double ans = 0.0;
        FOR(i, s + 5, 1){
            if(i - k <= 1) ans += (dp[0][i] * 1.0);
            else ans += (dp[0][i] * (i - k) * 1.0);
        }
        printf("%.8lf\n", ans);
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
double ans,dp[2][10000],s[2][10000];
int now,pre,n,m,k,i,j;
int main(){
while(1){
	scanf("%d%d%d",&n,&m,&k);
	if(n==0)return 0;
	memset(dp,0,sizeof(dp));
	memset(s,0,sizeof(s));
	for(i=1;i<=m;i++){
		dp[1][i]=1;s[1][i]=i;
	}
	for(i=m+1;i<=n*m;i++)s[1][i]=s[1][i-1];
	for(i=2;i<=n;i++){
		now=i&1;pre=now^1;
		memset(dp[now],0,sizeof(dp[now]));
		memset(s[now],0,sizeof(s[now]));
		for(j=i;j<=n*m;j++){
			dp[now][j]=s[pre][j-1];
			if(j>m)dp[now][j]-=s[pre][j-m-1];
			s[now][j]=s[now][j-1]+dp[now][j];
		}
	}
	ans=0;
	for(i=n;i<=n*m;i++){
		if(i<=k)ans+=dp[now][i];
		else ans+=dp[now][i]*(i-k);
	}
	for(i=1;i<=n;i++)ans/=m;
	printf("%.8f\n",ans);
}
}

C++: #include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
long long n,m,k,sum,p,q,power[10000];
int main(){
	while(true){
		cin>>n>>m>>k;if(!n){break;}
		power[0]=1;
		for(int i=1;i<=n;i++){power[i]=power[i-1]*m;}
		sum=0;
		for(int i=0;i<power[n];i++){
			p=0;
			for(int j=0;j<n;j++){
				q=(i/power[j])%m+1;
				p+=q;
			}
			sum+=max(1LL,p-k);
		}
		cout<<fixed<<setprecision(15)<<1.0*sum/power[n]<<endl;
	}
}

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

#define int long long

int n, m, k;

void solve(vector<int> &con, int depth, int sum){
  if(depth == n){
    con[sum]++;
    return ;
  }
  for(int i = 1; i <= m; i++){
    solve(con,depth+1,sum+i);
  }
  
}
signed main(){

  cout<<fixed<<setprecision(8);
  while(true){
    double ans = 0, temp;
    vector<int> con;
    
    cin>>n>>m>>k;

    if(!n&&!m&&!k) break;

    con.resize(n*m+2);
    
    solve(con, 0, 0);

    temp = pow(m,n);
    
    for(int i = n; i <= n*m; i++){
      ans += max(1ll, i-k)*con[i];
      //cout<<i<<" "<<con[i]<<endl;
    }

    ans /=temp;

    cout<<ans<<endl;
  }
  return 0;
}

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

int m;

double calc(int n, int s)
{
	if (n == 0) return max(1, s);
	double res = 0.0;
	for (int i = 1; i <= m; i++){
		res += calc(n - 1, s + i);
	}
	return res;
}

int main()
{
	int n, k;
	while (cin >> n >> m >> k, n){
		double res = calc(n, -k) / pow(m, n);
		printf("%.20f\n", res);
	}
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1){
    int n,m,k;
    cin>>n>>m>>k;
    if(!n)break;
    vector<double> prob(n*m+1);
    REP(i,m) prob[i+1] = 1.0/m;
    REP(i,n-1) {
      vector<double> sum(n*m+2);
      partial_sum(begin(prob),end(prob),begin(sum)+1);
      vector<double> nprob(n*m+1);
      REP(j,n*m+1) {
        nprob[j] = (sum[j] - sum[max(0,j-m)])/m;
      }
      prob.swap(nprob);
    }
    double ept = 0.0;
    REP(i,n*m+1) {
      ept += max(1, i-k) * prob[i];
    }
    cout << setprecision(10) << fixed << ept << endl;
  }
  return 0;
}