Artifact Content
Not logged in

Artifact d63ada0513560bce41ea7d1a204630cbf157065b


//-------------------------------------------------------------
// number of combinations choosing k out of n
// # you might better consider to use Pascal's triangle
// # for comb modulo some number...
//
// Verified by
//   - SRM 350 Div1 LV2
//-------------------------------------------------------------

LL comb(LL n, LL k)
{
	k = min(k, n-k);

	LL c = 1;
	for(LL i=0; i<k; ++i)
		c *= n-i, c /= i+1;
	return c;
}