1.
import java.util.Scanner;

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 530 - Binomial Showdown
* Link: http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=471
*
* @author Siegfried Ippisch
* @version 1.0
*
* Method : -
* Status : Accepted
* Runtime: 0.132
*/
public class BinomialShowdown {

public static void main(String[] args){
Scanner in = new Scanner(System.in);

int n = in.nextInt();
int k = in.nextInt();

while(n != 0){
System.out.println(f(n,k));
n = in.nextInt();
k = in.nextInt();
}

in.close();
}

public static int f(int n, int k){
k = Math.min(k, n-k);
double res = 1;
for(int i=0; i<k; i++){
res = res * (n-i);
res = res / (i+1);
}
return (int)(res+0.5);
}

}


2.

package acm_530_binomial_showdown;

import java.util.Scanner;

/**
 * FWP, Ausgew¦hlte Probleme aus dem ACM Programming Contest, SS10
 * Problem: acm_530_binomial_showdown
 * Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&page=show_problem&problem=305&Itemid=8
 *
 * @author Martin Lambeck
 * @version 1.0, 18.08.2010
 *
 * Method : adhoc
 * Status : Accepted
 * Runtime: 0.112
 */


public class Main
{
    static Scanner sc = new Scanner(System.in);

    public static void main(String... args)
    {
        while (testcase())
            ;
    }

    public static boolean testcase()
    {
       
        int n = sc.nextInt();
        int m = sc.nextInt();

        if ((n == 0) && (m==0))
            return false;
       
        double b = 1.0;
       
        double mi = 1.0;
        int ni = n;
       
        int mmax = Math.min(m, n-m);
       
        for (int i = 0; i < mmax; i++)
        {
            double v = ni / mi;
           
            b *= v;
           
            ni--;
            mi++;
        }

        System.out.println((int) (b+0.001));
        //System.out.printf("%d things taken %d at a time is %d exactly.%n",n, m, (int) (b+0.001));

        return true;
    }
}