[NYOJ] [1023] Taking Stones (I)

Problem Description

Loading...

Problem Analysis

Bash game

Winning strategy:
On each move, leave the opponent a multiple of (m+1) (take n%(m+1)).

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include<stdio.h>
int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		int n,m;
		scanf("%d %d",&n,&m);
		printf("%s\n",n%(m+1)?"Win":"Lose");
	}
	return 0;
}

Blog recommendation: NYOJ-23 Take Stones (I) - Kexiaochikuang - Blog Garden

Problem link: 【NYOJ】[1023] Take Stones (I)

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...