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 <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#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 pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

double d[100][10000];
int main(){
	int n,m,k;
	while(1){
		cin >> n >> m >> k;
		if(n==0&&m==0&k==0) break;
		REP(i,100) REP(j,10000) d[i][j] = 0;
		d[0][0] = 1.0;
		REP(i,n){
			REP(j,10000){
				// if(d[i][j]<0.00001) continue;
				FOR(p,1,m+1){
					d[i+1][j+p] += d[i][j]*(1.0/double(m));
				}
			}
		}
		double res = 0;
		REP(i,10000){
			 // if(d[n][i]!=0) cout << i << "  " << d[n][i] << endl;
			int num = max(i-k,1);
			res += d[n][i]*num;
		}
		cout << shosu(8) << res << endl;
	}
}

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

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const int MAX_SIZE=100005;
int n,m,k;
double p[2][MAX_SIZE];
void solve() {
    rep(i,MAX_SIZE) p[0][i]=p[1][i]=0.0;

    rep(i,m) p[0][i+1]=1.0/m;
    rep(i,n-1) {
        rep(j,MAX_SIZE) {
            rep(k,m) {
                p[1][k+j+1]+=p[0][j]/m;
            }
        }
        rep(j,MAX_SIZE) {
            p[0][j]=p[1][j];
            p[1][j]=0.0;
        }
    }
    double ans = 0.0;

    rep(i,m*n) {
        int b = max(1,i-k+1);
        //cout<<i+1<<" : "<<p[0][i+1]<<","<<b<<endl;
        ans += p[0][i+1]*b;
    }

    printf("%.8f\n",ans);
}

int main() {
    while(cin>>n>>m>>k) {
        if(n+m+k==0) break;
        solve();
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

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

double dp[30][20000];
//dp[サイコロの個数][目の合計]

double max(int i, int j)
{
	if (i > j) return (double)i;
	else return (double)j;
}

int main(void)
{
	int n, m, k;
	cin >> n >> m >> k;
	dp[0][0] = 1;
	rep(i, n) {
		erep(j, m * i) {
			orep(l, m) {
				dp[i + 1][j + l] += dp[i][j] / m;
			}
		}
	}

	double ans = 0;
	erep(i, m * n) ans += max(1, i - k) * dp[n][i];
	cout << fixed << setprecision(9) << ans << endl;
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int m, n, k;
int bunbo;
int bunshi = 0;

void calc(int res, int sum) { // resは残り回数。sumは今まで出た目の和。
  if (res == 0) {
    bunshi += (sum-k > 0) ? sum-k : 1;
  } else {
    for (int i=1; i<=m; i++) {
      calc(res-1, sum+i);
    }
  }
}

int main() {
  while(cin >> n >> m >> k && m) {
    bunshi = 0;
    calc(n, 0);
    bunbo = pow(m, n);
    // cerr << "bunshi = " << bunshi << ", bunbo = " << bunbo << endl;
    cout << fixed << setprecision(7) << (double)bunshi/bunbo << endl;
  }
}

C++: #include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m, k;

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,k;
double ans;
void saiki(int kai,int sum){
  if(kai >= n) ans += max(1,sum-k);
  else
    for(int i=1;i<=m;i++)saiki(kai+1,sum+i);
}

int main() {
  while(1) {
    cin >> n >> m >> k;
    if(n==0 && m==0 && k==0) break;
    ans = 0;
    saiki(0,0);
    int t = 1;
    for(int i=0;i<n;i++) t*=m;
    printf("%.8f\n",ans/t);
  }
  return 0;
}