Tap here to switch tabs
Problem
Submissions

Problem: Alice and Bob Playing Flower Game

Alice and Bob Playing Flower Game asks you to count pairs of clockwise and counterclockwise flower counts within given ranges where Alice takes the last flower when both play optimally.

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

Alice and Bob Playing Flower Game asks you to count pairs of clockwise and counterclockwise flower counts within given ranges where Alice takes the last flower when both play optimally.

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