UVA Problem Uva 369 – Combinations Solution

Problem Solving, UVa

 

 

#include <bits/stdc++.h>

using namespace std;



long double func_tion (long double n)

{

    long double i,r = 1;

    for ( i = 2; i <= n; i++)

    {

        r *= i;

    }

    return r;

}

int main ()

{

    long double M, N,r,n,m;

    while (cin>>N>>M)

    {

        if( N==0 and M==0 ) break;

        n=(func_tion(N));

        m=(func_tion(N-M)*func_tion(M));

        r = n/m;

           cout << N << " things taken " << M << " at a time is " << setprecision(0) << r << " exactly." << endl;

    }

    return 0;

}

 

0 Comments

You may find interest following article