codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

346A.md (1660B)


      1 Source: https://codeforces.com/problemset/problem/346/A
      2 
      3 A. Alice and Bob
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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).
     22 
     23 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.
     24 
     25 Input
     26 
     27 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 *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 109) — the elements of the set.
     28 
     29 Output
     30 
     31 Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes).
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 2  
     39 2 3
     40 ```
     41 
     42 Output
     43 
     44 ```
     45 Alice
     46 ```
     47 
     48 Input
     49 
     50 ```
     51 2  
     52 5 3
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 Alice
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 3  
     65 5 6 7
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 Bob
     72 ```
     73 
     74 Note
     75 
     76 Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.