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 <cmath>

using namespace std;

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

    int num[10000];
    for(int i=1;i<=n;i++) num[i]=1;
    bool end=false;
    double ans=0;
    double a=pow((double)m, (double)n);
    for(;;){
      int sum=0;
      for(int i=1;i<=n;i++){
	sum+=num[i];
      }
      if(sum<=k){
	ans+=1.0/a;
      }else{
	ans+=1.0/a*(double)(sum-k);
      }
      if(num[n]==m){
	num[n]=0;
	for(int t=n-1;;){
	  if(t<=0){
	    end=true;
	    break;
	  }
	  if(num[t]<m){
	    num[t]++;
	    break;
	  }else{
	    num[t]=1;
	    t--;
	  }
	}
	if(end) break;
      }
      num[n]++;
    }
    printf("%.10f\n", ans);
  }
  return 0;
}

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

map<pair<int, int>, int> mp;

int pow(int n, int m)
{
  if (m == 1) {
    return n;
  }
  if (m == 0) {
    return 1;
  }
  if (m % 2 == 1) {
    return n * pow(n, m - 1);
  }
  if (m % 2 == 0) {
    int a = pow(n, m / 2);
    return a * a;
  }
}

int comb(int n, int m, int k) {
  if (n == 1) {
    if (1 <= k && k <= m) {
      return 1;
    } else {
      return 0;
    }
  }
  int sum = 0;
  if (mp.find(make_pair(n, k)) != mp.end()) {
    return mp[make_pair(n, k)];
  } else {
    for (int i = 1; i <= m; i++) {
      if (i >= k) {break;}
      sum += comb(n - 1, m, k - i);
    }
  }
  mp[make_pair(n, k)] = sum;
  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;
    }
    mp.clear();
    int E = 0;
    for (int i = n; i <= k; i++) {      
      E += comb(n, m, i);
      //printf("%d %d %d = %d\n", n, m, i, comb(n, m, i));
    }
    for (int i = k + 1; i <= m * n; i++) {
      E += comb(n, m, i) * (i - k);
      //printf("%d %d %d = %d\n", n, m, i, comb(n, m, i));
    }
    printf("%.9lf\n", (double)E / pow(m, n));
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int n, m, k;
map<int, int> mp;
void dfs(int cnt, int total)
{
    if(cnt == n)
    {
        total = max(total - k, 1);
        mp[total]++;
        return;
    }
    for(int i = 1; i <= m; i++) dfs(cnt + 1, total + i);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    while(cin >> n >> m >> k, n or m or k)
    {
        mp.clear();
        dfs(0, 0);
        double ans = 0.0;
        for(auto x : mp) ans += x.first * x.second;
        cout << ans / pow(m, n) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

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

map<int, int> v;
int n, m, k;

void solve(int N, int value){
  if(N == 0){
    value -= k;
    if(value < 1) value = 1;
    v[value]++;
    return;
  }
  else{
    for(int i = 1 ; i <= m ; i++){
      solve(N-1, value+i);
    }
  }
}

int main(){
  while(cin >> n >> m >> k, n|m|k){
    v.clear();
    solve(n, 0);
    int M = 1;    
    rep(i, n) M *= m;
   
    double ans = 0.0;
    for(map<int, int>::iterator it = v.begin() ; it != v.end() ; it++){
      ans += double(((double)it->second * (double)it->first) / (double)M);
    }
    printf("%.8f\n", ans);    
  }  
  return 0;
}

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

int m,k;
int bill[100000];

void probability(int n,int sum)
{
  for(int i=1;i<=m;i++){
    if(n==1){
      int def=sum+i-k;
      if(def>0) bill[def]++;
      else bill[1]++;
    } else probability(n-1,sum+i);
  }
}

int main()
{
  int n;

  for(;;){
    cin>>n>>m>>k;
    if(!(n|m|k)) break;
    for(int i=0;i<=n*m-k;i++) bill[i]=0;
    probability(n,0);
    double sum=0;
    for(int i=1;i<=n*m-k;i++)
      sum+=bill[i]/pow(m,n)*i;
    printf("%.9f\n", sum);
  }
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int dice[100][1000001];

double A(int x, int y){
	int ret = 1;
	rep(i,x){
		ret *= y;
	}
	return (double)ret;
}

int main(){
	int n, m, k;
	while(scanf("%d%d%d", &n, &m, &k),n||m||k){
		double ans = 0.0;
		rep(i,n) rep(j,n*m+1) dice[i][j] = 0;
		for(int i = 1; i <= m; i++) dice[0][i] = 1;
		for(int i = 1; i < n; i++){
			for(int j = 1; j <= n*m; j++){
				for(int k = 1; k <= m; k++){
					dice[i][j+k] += dice[i-1][j];
				}
			}
		}
		int f = 0;
		for(int i = 0; i <= k; i++){
			f += dice[n-1][i];
		}
		ans += (double)f;
		for(int i = 1; i <= n*m-k; i++){
			ans += (double)dice[n-1][i+k]*i;
		}
		ans /= A(n,m);
		printf("%.9f\n", ans);
	}
}

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

typedef long long lli;

const int MAX = 10002;
int n,m,k;

void solve(){
  lli dp[2][MAX];
  fill(dp[0],dp[2],0);
  for(int i=1;i<=m;i++) dp[0][i] = 1;

  for(int i=1;i<n;i++){
    for(int j=1;j<MAX;j++){
      if(dp[0][j-1] > 0 && dp[0][j] == 0) break;
        for(int k=1;k<=m;k++){
          dp[1][j+k] += dp[0][j];
        }
    }
    for(int j=0;j<MAX;j++){
      dp[0][j] = dp[1][j];
      dp[1][j] = 0;
    }
  }

  lli ans = 0;
  for(int i=0;i<MAX;i++) ans += (lli)max(1,i-k) * dp[0][i];
  printf("%.8f\n",(double)ans / pow((double)m, (double)n));
}

int main(){
  while(cin >> n >> m >> k && (n|m|k)){
    solve();
  }
}

C++: #include "bits/stdc++.h"
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1286
using namespace std;
#define ll long long
int n, m, k;
void dfs(int now, int Sum,map<int,int>& M) {
	if (now == n) {
		M[max(Sum - k, 1)]++;
		return;
	}
	else {
		for (int i = 1; i <= m;i++) {
			dfs(now + 1, Sum + i, M);
		}
	}
	return;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (cin >> n >> m >> k) {
		if (n == 0 && m == 0 && k == 0)break;
		map<int, int> M;
		dfs(0, 0, M);
		double ans = 0;
		for (auto it = M.begin();it != M.end();it++) {
			//cout << it->first << " " << it->second << endl;
			ans += ((double)it->first) / (double)pow(m,n) *(it->second);
		}
		cout << fixed << setprecision(10) << ans << endl;
	}
}