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 <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

map<pair<int,int>,long long> dp;
int n,m,k;

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d%d%d",&n,&m,&k) && n!=0) {
		dp.clear();
		for (int i=0; i<n; i++) for (int j=0; j<=n*m; j++) dp[make_pair(i,j)] = 0;
		long long p = 1;
		for (int i=0; i<n; i++) p *= (long long)m;
		for (int i=0; i<n; i++) {
			for (int j=0; j<=n*m; j++) {
				for (int t=1; t<=m; t++) {
					if (i==0) dp[make_pair(i,t)] = 1;
					else {
						if (t+j<=m*n) dp[make_pair(i,t+j)] += dp[make_pair(i-1,j)];
					}
				}
			}
		}
		//for (int i=0; i<=m*n; i++) cout<<i<<" "<<dp[make_pair(n-1,i)]<<endl;
		long long ans = 0;
		for (int i=0; i<=k+1; i++) ans += dp[make_pair(n-1,i)];
		for (int i=k+2; i<=n*m; i++) ans += (long long)(i-k)*dp[make_pair(n-1,i)];
		printf("%.12lf\n",(double)ans/p); 
	}

    return 0;

}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<pair<int,int>,int> t;
#define mt(i,j,k) make_pair(make_pair((i),(j)),(k))
int n,m,k;
map<t,int> memo;
int dfs(int nRest, int dest){
  if(nRest*m<dest) return 0;
  if(nRest==1) return (1<=dest&&dest<=m?1:0);
  int &res=memo[mt(m,nRest,dest)];
  if(res!=0)return res;
  for(int i=1;i<=min(m,dest-1);i++){
    res+=dfs(nRest-1,dest-i);
  }
  return res;
}
void solve(){
  ll sum=0;
  for(int i=n;i<=n*m;i++)
    sum+=dfs(n,i)*max(1,i-k);
  printf("%.8lf\n",(double)sum/pow(m,n));
}
int main(){ _;
  while(cin>>n>>m>>k,(n|m|k)!=0){
    solve();
  }
}

C++: #include <cstdio>
#include <iostream>
using namespace std;
int main(){
  int n, m, k;
  while(cin >> n >> m >> k, n){
    long long int prob[n*m+1];
    fill(prob,prob+n*m+1,0LL);
    fill(prob+1,prob+m+1,1LL);
    //prob[0] = 1;
    long long int t = m;
    for(int i = 1; i < n; ++i){
      t *= m;
      int acum[m*(i+1)+1];
      fill(acum,acum+m*(i+1)+1,0);
      //cout << "acum = ";
      for(int j = 0; j <= m*(i+1); ++j){
	acum[j+1] = acum[j]+prob[j];
	//cout << acum[j] << " ";
      }//cout << acum[m*(i+1)] << endl;
      //cout << "prob = ";
      for(int j = 0; j < i; ++j) prob[j] = 0;
      for(int j = i; j <= m*(i+1); ++j){
	prob[j] = acum[j] - acum[max(0,j-m)];
	//cout << prob[j] << " ";
      }//cout << endl;;
    }
    double ans = 0.0;
    for(int i = n; i <= n*m; ++i){
      ans += (double)max(1,i-k)*prob[i]/t;
    }
    printf("%.12f\n",ans);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int dp[32768];
int main(void)
{
  cout << fixed << setprecision(10);
  for(;;){
    int n,m,k;
    cin >> n >> m >> k;
    if(!n&&!m&&!k) return 0;
    double answer=0.0;
    if(n==1){
      answer+=(LL)(m-k)*(m-k+1)/2;
      answer+=k;
      answer/=m;
      cout << answer << endl;
      continue;
    }
    REP(i,32768) dp[i]=0;
    dp[0]=1;
    REP(i,n){
      for(int i=20000;i>=0;--i){
	dp[i+1]+=dp[i];
	dp[i+m+1]-=dp[i];
	dp[i]=0;
      }
      REP(i,20000) dp[i+1]+=dp[i];
    }
    REP(i,20000) answer+=max(1,i-k)*dp[i];
    REP(i,n) answer/=m;
    cout << answer << endl;

  }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int N;
int M;
int K;
int t;

// n maisu k menowa
void rec(int n,int k){
  if(n==N){
    t+=(k-K>0)?k-K:1;
    return;
  }
  REP(i,1,M){
    rec(n+1,k+i);
  }
}

void run(){
  while(cin>>N>>M>>K,N){
    t=0;
    rec(0,0);
    double ans=(double)t;
    double p=pow(M,N);
    cout<<ans/p<<endl;
  }
}

C++: #include<iostream>
#include<iomanip>
#include<cmath>
#define MAX 100000
using namespace std;
int n,m,k;
int M[MAX];
 
void dfs(int a,int b,int cost)//a->n , b->m
{
  if(a >= n)
    {
      M[max(cost-k,1)]++;
      return;
    }
 
    for(int i=1;i<=m;i++)dfs(a+1,b+i,cost+i);
}
 
int main()
{
  while(cin >> n >> m >> k,n|m|k)
    {    
      for(int i=0;i<MAX;i++)M[i] = 0;     
      dfs(0,0,0);
      long double total = 0;
      for(int i=0;i<MAX;i++)total += i*M[i];
      cout << setiosflags(ios::fixed) << setprecision(8) << total/pow((double)m,(double)n) << endl;
    }
  return 0;
}

C++: #include<cstdio>
#define repi(a,b,c) for(int a=b;a<=c;a++)
using namespace std;
int main(){
	int n,m,k;
	while(scanf("%d%d%d",&n,&m,&k),n){
		int a[n*m+1],b[n*m+1],*prev=a,*cur=b,*t,ans=0,sum=0;
		repi(i,1,m)cur[i]=1;
		repi(i,2,n){
			t=prev,prev=cur,cur=t;
			repi(j,i,i*m)cur[j]=0;
			repi(x,1,m)repi(y,i-1,(i-1)*m)cur[x+y]+=prev[y];
		}
		repi(i,n,n*m)sum+=cur[i],ans+=(i-k>0?i-k:1)*cur[i];
		printf("%.9f\n",1.*ans/sum);
	}
	return 0;
}