본문 바로가기
#DevStudy/문제풀이

[Baekjoon] 9625 - BABBA

by 검은_백조 2016. 10. 13.


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


피보나치 문제.

A

B

BA = B + A

BAB = BA + B

BABBA = BAB + BA

....



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
 
#define MAX 50
int countA[MAX];
int countB[MAX];
 
int main() {
    int count;
    scanf("%d"&count);
 
    memset(countA, 0sizeof(int* MAX);
    memset(countB, 0sizeof(int* MAX);
 
    countA[2= 1;
 
    countB[1= 1;
    countB[2= 1;
 
 
    for(int i = 3; i <= count; i++){
        countA[i] = countA[i-2+ countA[i-1];
        countB[i] = countB[i-2+ countB[i-1];
    }
 
    printf("%d %d\n", countA[count], countB[count]);
 
 
 
 
    return 0;
}
cs



'#DevStudy > 문제풀이' 카테고리의 다른 글

[Baekjoon] 1932 - 숫자삼각형  (0) 2016.10.12
[Baekjoon] 2579 - 계단오르기  (0) 2016.10.11
[Baekjoon] 1149 - RGB  (0) 2016.10.11
[P.C] 3. 여행 (The trip)  (0) 2016.09.23
[P.C] 2. 지뢰찾기 (Minesweeper)  (0) 2016.09.23

댓글