杭电oj2070 c++

#include
using namespace std;
int main()
{
	_int64 a[50], n;
	a[0] = 0; a[1] = 1;
	while (cin >> n) {
		if (n == -1)
			break;
		for (int i = 2; i <= n; i++) {
			a[i] = a[i - 2] + a[i - 1];
		}
		cout << a[n] << endl;
	}
	return 0;
}

 

你可能感兴趣的:(OJ练习)