Cod sursa(job #1379045)

Utilizator andrei_diaconuAndrei Diaconu andrei_diaconu Data 6 martie 2015 15:58:30
Problema Sandokan Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>
#define NMax 5010
using namespace std;
ifstream f("sandokan.in");
ofstream g("sandokan.out");
int n, k, tmp, comb[NMax];
int main()
{
	f >> n >> k;
	int tmp = n;
	while (n >= k)
		n -= (k - 1);
	k = n - 1;
	n = tmp - 1;
	comb[0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = i; j >= 1; j--)
			comb[j] = comb[j] + comb[j - 1];
	g << comb[k];
}