문제 풀이/문제 풀이(BOJ)

[Silver V] BABBA - 9625

풀뿌리 2024. 9. 19. 12:29

[문제 위치]

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

[문제 풀이]

간단한 DP문제이다. 클릭시 일어나는 일을 구현해주면 된다.

#include <iostream>
#include <iomanip> 

#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

using namespace std;

int main() {
    fastio;
    int n, A = 1, B = 0;
    cin >> n;
    while (n--) {
        int tmp_A = A, tmp_B = B;
        B += tmp_A; //A가 B로 변함
        A -= tmp_A; //A가 B로 변함
        A += tmp_B; //B가 AB로 변함
    }

    cout << A << " " << B;
    return 0;
}