U E D R , A S I H C RSS

Counting/문보창

No older revisions available

No older revisions available



소감

2006-01-10 Accepted 0.057 Minimum
스터디 시간에 상섭이형이 발표한 점화식 이용.

코드

~cpp
// 10198 - Counting
#include "BigInteger.h"
using BigMath::BigInteger;

#define MAX_SIZE 1000

static BigInteger Tn[MAX_SIZE+1];

void preCalc()
{
	Tn[0] = 1;
	Tn[1] = 2;
	Tn[2] = 5;
	for (int i = 3; i <= MAX_SIZE; i++)
		Tn[i] = 2 * Tn[i-1] + Tn[i-2] + Tn[i-3];
}

int main()
{
	int n;
	preCalc();
	while (cin >> n)
		cout << Tn[n] << endl;
	return 0;
}
----
Counting
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:01
Processing time 0.0198 sec