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

부분합 더블릿

by tryotto 2019. 2. 9.
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
#include <stdio.h>
 
long long dp[1000= { 0 };
 
int main() {
    int n;
    scanf("%d"&n);
    getchar();
 
    int total = n*(n + 1/ 2;
    if (total % 2 == 1) {
        printf("0");
        return 0;
    }
        
    
    dp[0= 1;
 
    int tmp = 0;
    for (int j = 1; j <= n; j++) {
        for (int i = tmp; i >= 0; i--) {
            dp[i + j] += dp[i];
        }
        tmp+=j;
    }
 
    int rst = dp[total / 2/ 2;
    printf("%d", rst);
}
cs


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

9084 동전  (0) 2019.02.11
돌다리건너기 더블릿 (2602 백준)  (0) 2019.02.10
9251 LCS  (0) 2019.02.09
1149 RGB거리  (0) 2019.02.09
1463 1로 만들기  (0) 2019.02.08