fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7.  
  8. while (t--) {
  9. int n;
  10. cin >> n;
  11.  
  12. // Count numbers in each remainder class (mod 4)
  13. int count[4] = {0, 0, 0, 0};
  14.  
  15. for (int i = 0; i < n; i++) {
  16. count[i % 4]++;
  17. }
  18.  
  19.  
  20. if (count[0] != count[3] || count[1] != count[2]) {
  21. cout << "Alice\n";
  22. } else {
  23. // Both pairs are balanced
  24. // Alice wins if the total number of pairs is odd
  25. int total_pairs = count[0] + count[1]; // = count[3] + count[2]
  26. if (total_pairs % 2 == 1) {
  27. cout << "Alice\n";
  28. } else {
  29. cout << "Bob\n";
  30. }
  31. }
  32. }
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5320KB
stdin
5
2
4
5
7
100
stdout
Alice
Bob
Alice
Alice
Bob