We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 12acc57 commit f33472bCopy full SHA for f33472b
1 file changed
Codes/TwoStones.java
@@ -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