## DMOPC '15 Contest 7 P4 - Magic

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types

Two magicians named Alice and Bob participate in a challenge. The two participate in a race on a circular track split in equal-length sectors, determined by the points .

• Alice starts at point and runs through sectors per second.
• Bob starts at point and runs through sectors per second.

If at any point in the race the distance between the two is less than , Alice will use her magic to instantly push Bob a minimum distance such that the two magicians remain at a distance greater or equal to . The winning conditions are as follows:

• Alice wins if it is possible that sometime during the race, the sum of the shortest distance (running on the circular track) between herself to and Bob to is prime.
• Bob wins if Alice cannot.

In a given scenario, who wins?

#### Input Specification

The first line of input will contain the integers and .
The second line of input will contain the integers and .
The third line of input will contain the integers and .

#### Output Specification

Either Alice or Bob, identifying the winner.

#### Constraints

• .
• At least a turn is executed.
• In case Alice and Bob are on the same segment, Bob is pushed behind Alice.

#### Sample Input

6 2
2 3
0 1

#### Sample Output

Alice

#### Explanation

At the start, the positions of are , but immediately this changes to as Alice pushes Bob. In the second instant, we have the positions , such that the sum of distances to is . Since is a prime number, Alice wins.

• kobortor  commented on April 13, 2016, 8:47 p.m.

When the position is (0,2), why doesn't she win?

• bobbotboy  commented on April 13, 2016, 8:57 p.m.

Constraints: At least a turn is executed.

I think this means that each person must move once (by sA and sB units) before calculamatating whether prime or not.

• kobortor  commented on April 13, 2016, 9:06 p.m.

Then the testcase is weak, I submitted without checking if its the first run and got AC.

• jeffreyl  commented on April 12, 2016, 6:48 p.m.

What happens if K=0? Does Bob simply win as Alice cannot?

• WallE256  commented on April 12, 2016, 6:51 p.m. edit 2

During rewriting, the constraint of K was changed accidentally. So, . Text was changed.

• d  commented on April 12, 2016, 5:11 p.m. edited
100 2
35 2
0 10

Edit: Alice and Bob don't really run in a continuous motion, they teleport sectors every second.