본문 바로가기
알고리즘/DP

2193 이친수

by tryotto 2019. 7. 5.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
 
int main() {
    long long n;
    scanf("%lld"&n);
 
    if (n == 1 || n == 2 ) {
        printf("1");
        return 0;
    }
 
    long long a = 1, b = 1, c = 0;
    for (int i = 3; i <= n; i++) {
        c = a + b;
        a = b;
        b = c;
    }
 
    printf("%lld", c);
}
cs


'알고리즘 > DP' 카테고리의 다른 글

2579 계단오르기  (0) 2019.07.05
9095 1,2,3 더하기  (0) 2019.07.05
(미해결) buy lower 더블릿  (0) 2019.02.23
색종이 더블릿 (업시퀀스)  (0) 2019.02.21
블록쌓기 더블릿 (업시퀀스)  (0) 2019.02.21