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<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m,k;
	while(cin>>n>>m>>k,n+m+k){
		vvi dp(n+1,vi(n*m+1));
		dp[0][0]=1;
		rep(i,n)rep(j,n*m+1)if(dp[i][j])loop(x,1,m+1)if(j+x<=n*m){
			dp[i+1][j+x]+=dp[i][j];
		}
		ll out=0;
		rep(i,n*m+1)out+=dp[n][i]*max(1,i-k);
		cout<<shosu(9)<<out/pow(m,n)<<endl;
	}
}

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

using namespace std;

int n, m, k;
double ans;

void dfs(int node, int sum) {
    if (node == n) {
        if (sum-k < 1) sum = 1;
        else sum -= k;
        ans += sum;
        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;
        dfs(0, 0);
        printf("%.12lf\n", ans / pow(m,n));
    }
}

C++: #include<iostream>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;

int n, m;
map<int, int> data;

void solve(int sum, int n_){
  for(int i=1; i<=m; ++i){
    if(n_ == n) ++data[sum+i];
    else solve(sum+i, n_+1);
  }
}

int main(){
  int k;
  double ans, all;
  while(1){
    cin >> n >> m >> k;
    if(!n && !m && !k) break;
    data.clear();
    for(int i=n; i<n*m; ++i) data.insert(make_pair(i, 0));
    solve(0, 1);
    ans = 0;
    all = pow((double)m, n);
    for(map<int, int>::iterator it=data.begin(); it!=data.end(); ++it){
      if(it->first - k <= 1)
	ans += (it->second / all);
      else
	ans += ((it->first - k) * it->second / all);
    }
    printf("%0.8f\n", ans);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    double x,y,z,p;
    double s;
    while(cin>>x>>y>>z){
            if(x==0 && y==0 && z==0){
                break;
            }
            else if(x==0 && y!=0 && z!=0){

        p=y*z;
            }
            else if(x!=0 && y==0 && z!=0){
                p=x*z;
            }
            else if(x!=0 && y!=0 && z==0){
                p=x*y;
            }
            else if(x!=0 && y!=0 && z!=0){
                p=x*y*z;
            }

    s=(1/p + 2/p + 3/p) * 1 + 4/p * 2 + 5/p * 3 + 6/p * 4 + 5/p * 5 + 4/p * 6 + 3/p * 7 + 2/p * 8 + 1/p * 9;
    cout<<s<<endl;
    }

    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

void solve(int n, int m, int k) {
    vector<vector<double> > dp(n + 1, vector<double>(n * m + 1, 0.0));
    dp[0][0] = 1.0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n * m; j++) {
            for (int k = 1; k <= m; k++) {
                if (j - k < 0) continue;
                dp[i][j] += dp[i - 1][j - k] / m;
            }
        }
    }
    vector<double> ans(n * m - k + 1, 0.0);
    for (int i = 1; i <= n * m; i++) {
        ans[max(1, i - k)] += dp[n][i];
    }
    double res = 0.0;
    for (int i = 1; i <= n * m - k; i++) {
        res += i * ans[i];
    }
    cout << fixed << setprecision(8);
    cout << res << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    while (true) {
        cin >> N >> M >> K;
        if (N == 0 && M == 0 && K == 0) break;
        solve(N, M, K);
    }
    return 0;
}

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

map< pair<int,int> ,double> dp;

int n,m,k;
double dfs(int sum,int n){
	if( dp.count(make_pair(sum,n)) ) return dp[make_pair(sum,n)];
	if( sum < 0 ) return 0.0;
	if( sum == 0 ){	
		return n == 0 ? 1.0 : 0.0;
	}
	if( n <= 0 ) return 0.0;
	double res = 0;
	for(int i = 1 ; i <= m ; i++){
		res += dfs(sum-i,n-1) / m;
	}
	return dp[make_pair(sum,n)] = res;
}

int main(){
	while( cin >> n >> m >> k && n){
		dp.clear();
		double sum = 0;
		if( n == 1 ){
			for(int i = 1 ; i <= m ; i++)
				sum += (1./m) * max(1,(i-k));
		}else{
			for(int i = 1 ; i <= n * m ; i++){
				double p = dfs(i,n);
				sum += max(1,i-k) * p;
			}
		}
		printf("%.10lf\n",sum);
	}
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N=5000000;
double dp[N],dp2[N];

int main()
{
    int n,m,k;
    while(cin >>n >>m >>k,n|m|k)
    {
        memset(dp,0,sizeof(dp));
        dp[0]=1;

        rep(i,n)
        {
            memset(dp2,0,sizeof(dp2));

            for(int j=i; j<=m*i; ++j)
            {
                for(int k=1; k<=m; ++k)
                {
                    if(j+k>=N) break;
                    dp2[j+k]+=dp[j]/m;
                }
            }

            rep(j,N) dp[j]=dp2[j];
        }

        double ans=0;
        rep(i,N) ans+=max(1,i-k)*dp[i];

        printf("%.10lf\n",ans);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <string.h>

#define MAX 10000000

int dp1[MAX];
int dp2[MAX];

using namespace std;

int main(void)
{
	int n,m,k;
	int i1,i2,i3;
	double ans;
	double poww;

	while(1){
		cin>>n>>m>>k;
		if(n+m+k==0) break;

		memset(dp1,0,sizeof(dp1));
		memset(dp2,0,sizeof(dp2));

		for(i1=1;i1<=m;i1++){
			dp1[i1]=1;
		}

		for(i1=1;i1<n;i1++){
			for(i2=1;i2<=n*m;i2++){
				if(dp1[i2]!=0){
					for(i3=1;i3<=m;i3++) dp2[i2+i3]+=dp1[i2];
				}
			}

			for(i2=1;i2<=n*m;i2++){
				dp1[i2]=dp2[i2];
				dp2[i2]=0;
			}
		}

		/*	for(i3=0;i3<=n*m;i3++){
				cout<<i3<<" "<<dp1[i3]<<endl;
			}*/

		ans=0;
		poww=pow((double)m,n);

		for(i1=1;i1<=n*m;i1++){
			if((i1-k)<=0) {
				ans+=(dp1[i1]/poww);
				//cout<<"1 "<<dp1[i1]<<" "<<poww<<endl;
			}
			else {
				ans+=((dp1[i1]/poww)*(double)(i1-k));
				//cout<<i1-k<<" "<<dp1[i1]<<" "<<poww<<endl;
			}
		}

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

	}
	return 0;
}