Favourite Numbers solution codechef

Favourite Numbers solution codechef

  • Alice likes numbers which are even, and are a multiple of 7.
  • Bob likes numbers which are odd, and are a multiple of 9.

Alice, Bob, and Charlie find a number .

  • If Alice likes , Alice takes home the number.
  • If Bob likes , Bob takes home the number.
  • If both Alice and Bob don’t like the number, Charlie takes it home.

Given , find who takes it home.

Note: You can prove that there is no integer  such that both Alice and Bob like it.

Favourite Numbers solution codechef

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of a single integer, .

Output Format

For each test case, output on a new line who takes the number home – “Alice”, “Bob”, or “Charlie”.

You may print each character in uppercase or lowercase. For example, AlicealiceaLiCe, and ALICE are all considered identical.

Constraints

  • 1≤�≤100
  • 1≤�≤1000

Subtasks

  • Subtask 1 (10 points): 1≤�≤10
  • Subtask 2 (20 points): The sum of  across all test cases won’t exceed 20.
  • Subtask 3 (70 points): No further constraints.

Sample 1:

Input

Output

8
7
14
21
18
27
63
126
8
Charlie
Alice
Charlie
Charlie
Bob
Bob
Alice
Charlie

Explanation:

Testcase 1: 7 is not even, hence Alice doesn’t like it. It is odd, but isn’t a multiple of 9. Hence Bob doesn’t like it. Therefore, Charlie takes it home.

Testcase 2: 14 is even and a multiple of 7. Therefore, Alice likes it and takes it home.

Testcase 3: 21 is not even, hence Alice doesn’t like it. It is odd, but isn’t a multiple of 9. Hence Bob doesn’t like it. Therefore, Charlie takes it home.

Testcase 4: 18 is even but not a multiple of 7, hence Alice doesn’t like it. It is not odd, and hence Bob doesn’t like it. Therefore, Charlie takes it home.

Testcase 5: 27 is odd and a multiple of 9. Therefore, Bob likes it and takes it home.

Testcase 6: 63 is odd and a multiple of 9. Therefore, Bob likes it and takes it home.

Testcase 7: 126 is even and a multiple of 7. Therefore, Alice likes it and takes it home.

Testcase 8: 8 is even but not a multiple of 7, hence Alice doesn’t like it. It is not odd, and hence Bob doesn’t like it. Therefore, Charlie takes it home.

Leave a Reply

Your email address will not be published. Required fields are marked *