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 <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m, cutback;
        cin >> n >> m >> cutback;
        if(n == 0)
            return 0;

        vector<int> p(n*m+1, 0);
        p[0] = 1;
        for(int i=0; i<n; ++i){
            for(int j=m*i; j>=i; --j){
                for(int k=1; k<=m; ++k)
                    p[j+k] += p[j];
                p[j] = 0;
            }
        }

        int pSum = accumulate(p.begin(), p.end(), 0);
        double ret = 0;
        for(int i=0; i<n*m+1; ++i)
            ret += max(i-cutback, 1) * p[i] / (double)pSum;

        printf("%.10f\n", ret);
    }
}

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

int solve(){
    int n, m, k;
    cin >> n >> m >> k;
    if(n == 0) return 1;
    vector<vector<double> > dp(n+1, vector<double>(n*m+1, 0.0));  // dp[i][j] サイコロをi個振って和がj
    dp[0][0] = 1.0;
    for(int i=0;i<n;i++){
        for(int j=i;j<=i*m;j++){
            for(int k=1;k<=m;k++){
                dp[i+1][j+k] += dp[i][j]/m;
            }
        }
    }
    double ans = 0.0;
    for(int i=0;i<=n*m;i++){
        ans += max(i-k,1)*dp[n][i];
    }
    printf("%.8lf\n",ans);
    return 0;
}

int main(){
    while(solve()==0);
    return 0;
}

C++: #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

int n, m, K, d, a[100];
double ans;

void dfs(int cur){
    if(cur == n){
        int sum = 0;
        rep(i, n) sum += a[i];
        ans += 1.0 * max(1, sum-K) / d;
        return;
    }
    For(i, 1, m+1){
        a[cur] = i;
        dfs(cur+1);
    }
}

int main(){
    while(scanf("%d%d%d", &n, &m, &K) && n){
        d = 1;
        rep(_, n) d *= m;
        ans = 0;
        dfs(0);
        printf("%.20lf\n", ans);
    }
}

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

using namespace std;

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

double solve(int n, int m, int k){
    vector<int> cnt(1, 1);
    int T = 0;
    rep(i, n){
        vector<int> nxt(T + m + 1, 0);
        for(int j=0; j<=T; ++j)if(cnt[j]){
            for(int x=1; x<=m; ++x)nxt[j+x] += cnt[j];
        }
        nxt.swap(cnt);
        T += m;
    }
    int sum = 0;
    for(int i=1; i<=T; ++i)sum += max(1, i - k) * cnt[i];
    return sum / pow(m, n);
}

int main(){
    int n, m, k;
    while(cin >> n >> m >> k, n|m|k){
        cout << fixed << setprecision(9) << solve(n, m, k) << '\n';
    }
    return 0;
}

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

int comb(int n, int m, int k)
{
  if (n == 1) {
    if (1 <= k && k <= m) {return 1;}  
    else {return 0;}
  }
  if (k > m * n || k < n) {return 0;}
  
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    if (i >= k) {break;}
    sum += comb(n - 1, m, k - i);
  }
  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;}
    double E = 0;
    for (int i = n; i <= n * m; i++) {
      if (i <= k) {
	E += (double)comb(n, m, i) / pow((double)m, n);
      } else {
	E += (double)comb(n, m, i) / pow((double)m, n) * (i - k);
      }
    }
    printf("%lf\n", E);
  }
  return 0;
}

C++: // I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
void solve(){
  ll n,m,k,point;
  double ans=0;
  cin >> n >> m >> k;
  if(n==0&&m==0) return;
  vector<double> val(n*m+1,0);
  val[n] = 1;
  for(int i=0;i<n;i++){
    for(int j=n*m;j>=0;j--){
      if(j-m>=0){
        val[j] -= val[j-m];
      }
    }
    for(int j=0;j<=n*m;j++){
      val[j] /= m;
    }
  }
  for(int i=0;i<n;i++){
    for(ll j=1;j<=n*m;j++){
      val[j] += val[j-1];
    }
  }
  for(int i=1;i<=n*m;i++){
    point = max(1ll,i-k);
    ans += val[i]*point;
  }
  cout << ans << endl;
  solve();
}
signed main(){
  init_io();
  solve();
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, m, k;
double sum[100100];
double cntd[100100];

void solve(int num, int cnt) {
	if (cnt == n) {
		cntd[num]++;
		return;
	}
	FOR(i, 1, m + 1)solve(num + i, cnt + 1);
}

int main() {
	while (cin >> n >> m >> k&&n + m + k) {
		fill(sum, sum + 100100, 0);
		fill(cntd, cntd + 100100, 0);
		double t = pow(m, n);
		ll lb = n, ub = n*m;
		double num = 1;
		solve(0, 0);
		while (1) {
			//cout << lb << " " << ub << " ";
			//cout << num << endl;
			if (lb == ub) {
				if (lb > k)sum[lb] += cntd[lb];
				else sum[k + 1] += cntd[lb];
				break;
			}
			else {
				if (lb > ub)break;
				if (lb > k)sum[lb] += cntd[lb];
				else sum[k + 1] += cntd[lb];
				if (ub > k)sum[ub] += cntd[lb];
				else sum[k + 1] += cntd[lb];
			}
			lb++;
			ub--;
		}
		double ans = 0;
		REP(i, n*m + 1) {
			double num = i;
			//cout << i << " " << sum[i] << " " << sum[i] / t << endl;
			ans += (sum[i] / t)*(num - k);
		}
		printf("%.10lf\n", ans);
	}
}