#include <stdio.h>
enum{red_green, red_blue, green_blue, green_red, blue_red, blue_green};
int L, R, M, movement[4001][2001][6] = { 0 }; //movement[L+R][M][color_forward]
int fact(int x){
if (x == 0) return 1;
return x*fact(x - 1);
}
int main(){
int comb;
scanf("%d %d %d", &L, &R, &M);
movement[0][0][4] = 1;
for (int m = 0; m <= M; ++m){
for (int t = 0; t <= L + R; ++t){
for (int i = 0; i < 3; ++i){
if (movement[t][m][2 * i] >= 1000000007)
movement[t][m][2*i] %= 1000000007;
if (movement[t][m][2 * i+1] >= 1000000007)
movement[t][m][2*i+1] %= 1000000007;
if (t < L + R){
movement[t + 1][m][2 * i] += movement[t][m][2 * i + 1];
movement[t + 1][m][2 * i + 1] += movement[t][m][2 * i];
}
if (m < M){
movement[t][m + 1][2 * i] += movement[t][m][(2 * i + 4) % 6];
movement[t][m + 1][2 * i + 1] += movement[t][m][(2 * i + 3) % 6];
}
}
}
}
comb = fact(L + R) / fact(L) / fact(R);
for (int i = 0; i < 3; ++i){
printf("%d\n", (comb * (movement[L + R][M][2 * i] + movement[L + R][M][2 * i + 1]) % 1000000007) % 1000000007);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
32768 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |