HDU1261解题报告

中文题意略。
就是要求排列组合a1Cn * a2C(n-a1) * a3C(n - a1 - a2)…………
不过要高精就是了。

通过这个题学到了高精度排列组合公式的简洁写法。同时掌握了高精乘法和除法。


void bign(int a, int n)//总值乘以n,除以a
{
	int c = 0;
	int i, j;

	for (j = 0; j < N; ++j) //高精乘法
	{
		c = sum[j] * n + c;
		sum[j] = c % 10;
		c = c / 10;
	}
	c = 0;
	for (j = N - 1; j >= 0; --j) //高精除法
	{
		c = sum[j] + c * 10;
		sum[j] = c / a;
		c = c % a;
	}
}

猜你喜欢

转载自qq1214917885.iteye.com/blog/2200027