알고리즘

C++ 알고리즘 - 2193 이친수

마루설아 2025. 2. 13. 10:57

https://www.acmicpc.net/problem/2193

 

#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

/******** 전역변수 ********/
long long num[100];

/******** 함    수 ********/


int main(void) {
	/******** C++ INIT ********/
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	/******** 지역변수 ********/
	int input;

	/******** 구    현 ********/
	cin >> input;

	num[1] = 1;
	num[2] = 1;

	// 개수는 1, 1, 2, 3, 5, 8 .. 이다
	for (int i = 3; i < 100; i++) {
		num[i] = num[i - 1] + num[i - 2];
	}

	cout << num[input];
}