Skip to content

Commit f33472b

Browse files
authored
Add files via upload
1 parent 12acc57 commit f33472b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Codes/TwoStones.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//Alice and Bob are playing a new game of stones. There are N
2+
//stones placed on the ground, both picks up stones consecutively
3+
//If the number of stone left is odd, Alice wins. Otherwise, Bob wins.
4+
//Assume both Alice and Bob play optimally and Alice plays first, do you know who the winner is?
5+
6+
//Sample solution for https://open.kattis.com/problems/twostones
7+
8+
import java.io.BufferedReader;
9+
import java.io.IOException;
10+
import java.io.InputStreamReader;
11+
12+
public class TwoStones {
13+
14+
public static void main(String[] args) throws IOException {
15+
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
16+
17+
int stones = Integer.parseInt(reader.readLine());
18+
System.out.println(stones % 2 == 1 ? "Alice" : "Bob");
19+
}
20+
}

0 commit comments

Comments
 (0)