-
Notifications
You must be signed in to change notification settings - Fork 0
/
Favourite Numbers
55 lines (51 loc) · 1.06 KB
/
Favourite Numbers
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Favourite Numbers
Problem
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 A.
If Alice likes A, Alice takes home the number.
If Bob likes A, Bob takes home the number.
If both Alice and Bob don't like the number, Charlie takes it home.
Given A, find who takes it home.
input:=
8
7
14
21
18
27
63
126
8
output:=
Charlie
Alice
Charlie
Charlie
Bob
Bob
Alice
Charlie
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int A=sc.nextInt();
if(A%2==0 && A%7==0){
System.out.println("Alice");
}else if(A%2!=0 && A%9==0){
System.out.println("Bob");
}else{
System.out.println("Charlie");
}
}// your code goes here
}
}