
백준 2747번: 피보나치 수
·
PS
문제n이 주어졌을 때, n번째 피보나치 수를 구하는 프로그램을 작성하시오. 실행 결과 코드(c++)#include using namespace std;int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int a = 0; // Fn-2 int b = 1; // Fn-1 long int c = 0; // Fn if (n == 1) { c = 1; } else { for (int i = 1; i 코드 설명같은 난이도끼리 비교했을 때 비교적 쉬운 문제였다.문제에 따르면 n=17일때 까지 피보나치 수를 써보면 다음과 같다.0, 1, 1, 2, 3, 5, 8, 13,..