codeforce 347c
2017-10-22 19:02
274 查看
It is so boring in the summer holiday, isn’t it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn’t contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one).
If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first.
Input
The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, …, an (1 ≤ ai ≤ 109) — the elements of the set.
Output
Print a single line with the winner’s name. If Alice wins print “Alice”, otherwise print “Bob” (without quotes).
Example
Input
2
2 3
Output
Alice
Input
2
5 3
Output
Alice
Input
3
5 6 7
Output
Bob
If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first.
Input
The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, …, an (1 ≤ ai ≤ 109) — the elements of the set.
Output
Print a single line with the winner’s name. If Alice wins print “Alice”, otherwise print “Bob” (without quotes).
Example
Input
2
2 3
Output
Alice
Input
2
5 3
Output
Alice
Input
3
5 6 7
Output
Bob
import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.Scanner; /** * Created by 95112 on 10/22/2017. */ public class ABGame { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] input = new int ; int max = 0; for (int i = 0 ; i < n ; i++) { input[i] = scanner.nextInt(); if (max < input[i]) max = input[i]; } int v = input[0]; for (int i = 1 ; i < n ; i++) { v = gcd(v,input[i]); } v = max/v - n; if (v%2 == 1) System.out.println("Alice"); else System.out.println("Bob"); } private static int gcd(int a, int b){ if (a < b) { a = b+a; b = a - b; a = a - b; } if (a%b == 0) return b; else return gcd(b,a%b); } }
相关文章推荐
- codeforce #387 D. Winter Is Coming
- codeforce round A. Binary Protocol
- codeforce 897B
- codeforce_845c_Two TVs
- codeforce 402A - Nuts
- CodeForce 126B
- codeforce-1
- codeforce 766D Mahmoud and a Dictionary 带权并查集
- Codeforce172 Div2
- codeforce 168#div2 B题
- codeforce 66C. Petya and File System(MAP)
- Codeforce 题目337 C. Harmony Analysis(递归)
- Codeforce#181 div2 C,E--problem 300E,300C
- codeforce 18B
- CodeForce Round #186 Div.2
- codeforce 124B——全排列dfs——Permutations
- codeforce-B. Sort the Array
- codeforce 192 div2解题报告
- codeforce 864C Bus(模拟)
- codeforce #200 div2 的水题三道