U E D R , A S I H C RSS

Polynomial Coefficients/문보창

No older revisions available

No older revisions available



소감

2005/02/19 Accepted 0:00.025 64
입력받는 수가 12까지가 아니라면, 더 최적화된 알고리즘을 찾아야 한다.

코드

~cpp 
// no10105 - Polynomial Coefficients
#include <iostream>
using namespace std;

void main()
{
	int n, k, i, j, temp1, temp2, coeffi;
	while (cin >> n >> k)
	{
		temp1 = temp2 = 1;
		for (i=0; i<k; i++)
		{
			cin >> coeffi;
			if (coeffi)
			{
				for (j=1; j<=coeffi; j++)
					temp2 *= j;
			}
		}
		for (i=1; i<=n; i++)
			temp1 *= i;
		cout << temp1/temp2 << endl;
	}
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:24:01
Processing time 0.0277 sec