Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
841 B
2
Indexable
Never
#include <stdio.h>
#include <stdlib.h>

int ans, n;

void cal(int a, int b, int c, int type, int cnt) {
    if (cnt == n) {
        ans++;
        return;
    }
    if (type == 1) {
        if (b) cal(a, b - 1, c, 2, cnt + 1);
        if (c) cal(a, b, c - 1, 3, cnt + 1);
    }
    if (type == 2) {
        if (a) cal(a - 1, b, c, 1, cnt + 1);
        if (c) cal(a, b, c - 1, 4, cnt + 1);
    }
    if (type == 3) {
        if (b) cal(a, b - 1, c, 2, cnt + 1);
        if (c) cal(a, b, c - 1, 3, cnt + 1);
    }
    if (type == 4) {
        if (a) cal(a - 1, b, c, 1, cnt + 1);
        if (c) cal(a, b, c - 1, 4, cnt + 1);
    }
}

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    n = a + b + c;
    cal(a, b, c, 1, 0);
    cal(a, b, c, 2, 0);
    cal(a, b, c, 3, 0);
    cal(a, b, c, 4, 0);
    printf("%d", ans / 2);
}
Leave a Comment