Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		N, K, S := io.NextInt(), io.NextInt(), io.NextInt()
		if N == 0 {
			break
		}
		dp := [21][11][156]int{}
		for i := 0; i <= N; i++ {
			dp[i][0][0] = 1
		}
		for i := 1; i <= N; i++ {
			for j := 1; j <= K; j++ {
				for k := 1; k <= S; k++ {
					if k-i >= 0 {
						dp[i][j][k] += dp[i-1][j-1][k-i]
					}
					dp[i][j][k] += dp[i-1][j][k]
				}
			}
		}
		io.Println(dp[N][K][S])
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

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

int main(){
    int n,k,s,i,c,res;
    while(1){
        scanf("%d",&n);
        scanf("%d",&k);
        scanf("%d",&s);
        if(!n && !k && !s){break;}
        vector<int> t(n,0);
        int cd[n];
        iota(cd,cd+n,1);
        for(i=0;i<k;i++){t[n-i-1]=1;}    
        res=0;
        do{
            c=0;
            for(i=0;i<n;i++){c+=(t[i]*cd[i]);}
            if(c==s){res++;}
        } while(next_permutation(t.begin(),t.end()));
        printf("%d\n",res);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int n,k,s,cnt;
void a(int q,int p,int f){
  if(f==k){
    if(s==q) cnt++;
  }else for(int i=p+1;i<=n;i++)a(i+q,i,f+1);
}

int main(){
  while(1){
    cin>>n>>k>>s;
   if(n+k+s==0) break;
   cnt=0;
   for(int i=1;i<=n;i++) a(i,i,1);
   cout<<cnt<<endl;
  }
     return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 dfs(int64 n, int64 k, int64 s) {
	if (k == 0) return s == 0;
	if (s < k || n <= 0) return 0;
	return dfs(n-1, k, s) + dfs(n-1, k-1, s-n);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 n, k, s;
	while (cin >> n >> k >> s && n+k+s) {
		cout << dfs(n, k, s) << endl;
	}
}

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

int dp[22][11][202];    // dp[i][j][k]: i番目までの要素でj個用いて合計kとなるような組み合わせ

void solve(int n, int k, int s) {
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            for (int l = 0; l <= s; l++) {
                dp[i][j][l] = 0;
            }
        }
    }
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i][1][i] = 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            for (int l = 0; l <= s; l++) {
                dp[i][j][l] += dp[i - 1][j][l];
                if (l - i >= 0 && j > 1) dp[i][j][l] += dp[i - 1][j - 1][l - i];
            }
        }
    }
    cout << dp[n][k][s] << endl;
}

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