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
| #include <bits/stdc++.h> using namespace std;
bool dfs(int c0, int c1, int c2, int c3) { if (c0 == 0 && c1 == 0) return false; if (c0 == 0 && c1 == 1 && c2 == 0) return false; if (c0 > 0 && !dfs(c0 - 1, c1, c2, c3)) return true; if (c1 >= 2 && !dfs(c0, c1 - 2, c2 + 1, c3)) return true; if (c1 > 0 && c2 > 0 && !dfs(c0, c1 - 1, c2 - 1, c3 + 1)) return true; return false; }
int main() { int T; scanf("%d", &T); for (int t = 1; t <= T; ++t) { int c0, c1, c2, c3; scanf("%d %d %d %d", &c0, &c1, &c2, &c3); bool f; if (c0 + c1 + c2 + c3 == 0) f = false; else if (c1 + c2 + c3 == 0 && c0 % 2 == 1) f = false; else if (c1 + c2 + c3 == 0 && c0 % 2 == 0) f = true; else f = dfs(c0 % 2, c1 % 3, c2, c3); printf("Case #%d: ", t); f ? puts("Rabbit") : puts("Horse"); } }
|