Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew 🚀
Contest SolutionsPractice
Practice Sheets
MasterclassesLive 👨🏻‍💻

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
© 2026coding75•crackDSA™•Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021•Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/CodeChef/Starters 123/Yet Another Alice Bob Game
Prev
CodeChefCodeChef
5 Star
Starters 123

Yet Another Alice Bob Game

Game TheoryMath
Loading...
Solve on CodeChef

Problem Statement

Official algorithmic problem description and constraints.

Open on CodeChef

Alice and Bob play a game on a pile of N stones.


In her turn, Alice can remove at least one and at most A stones while Bob can remove at least one and at most B stones on his turn.

The person who takes the last stone wins.

Predict the winner of the game if Alice goes first (and turns alternate) under optimal play from both players.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of multiple lines of input.
  • The first line of each test case contains three space-separated integers, N, A, and B, the number of stones, and the maximum number of stones Alice and Bob can remove in one move respectively.


Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Starters 123
Previous Problem