Tap here to switch tabs
Problem
Submissions

Problem: Alice and Bob Playing Flower Game

Try to solve the Alice and Bob Playing Flower Game problem.

Statement

Alice and Bob are playing a turn based game on a circular field surrounded by flowers. There are xx flowers clockwise and yy flowers counterclockwise around the circle.

The rules of the game are as follows:

  • Alice moves first.

  • In each turn, the current player must pick 11 flower from either the clockwise direction or the counterclockwise direction.

  • The player who picks the last flower wins the game.

Given two integers n and m, determine the number of pairs (x,y)(x, y) such that 1≤x≤1 \le x \le n, 1≤y≤1 \le y \le m, and Alice wins the game assuming both players play optimally.

Constraints:

  • 1≤1 \le n, m ≤105\le 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Alice and Bob Playing Flower Game

Try to solve the Alice and Bob Playing Flower Game problem.

Statement

Alice and Bob are playing a turn based game on a circular field surrounded by flowers. There are xx flowers clockwise and yy flowers counterclockwise around the circle.

The rules of the game are as follows:

  • Alice moves first.

  • In each turn, the current player must pick 11 flower from either the clockwise direction or the counterclockwise direction.

  • The player who picks the last flower wins the game.

Given two integers n and m, determine the number of pairs (x,y)(x, y) such that 1≤x≤1 \le x \le n, 1≤y≤1 \le y \le m, and Alice wins the game assuming both players play optimally.

Constraints:

  • 1≤1 \le n, m ≤105\le 10^5