There are a pile of N items, two people take things from the pile of items in turn, requires at least p each time, a maximum of Q. The final winner wins.
N = (m + 1) R + S, (R is any natural number, S ≤ m), that is, N % (p + q )! = 0, the first accessors will surely win (the last one is win by default)
/*************************************** **************************************** # Author: neo Fung # Email: neosfung@gmail.com # Last modified: 2012-07-19 # filename: hdu2149 public sale. CPP # Description: There are n items in a heap. Two people take things from the heap in turn. It is required that at least P items be taken each time, and a maximum of Q items can be taken. the final winner wins. N = (m + 1) R + S, (R is any natural number, S ≤ m), that is, N % (p + q )! = 0, the first accessors will surely win (the last one is win by default) **************************************** **************************************/# ifdef _ msc_ver # define debug # DEFINE _ crt_secure_no_deprecate # endif # include <fstream> # include <stdio. h> # include <iostream> # include <string. h> # include <string> # include <limits. h> # include <algorithm> # include <math. h> # include <numeric> # include <functional> # include <ctype. h> using namespace STD; cons T int Kmax = 10010; const double Keps = 10e-6; int main (void) {# ifdef debug freopen (".. /stdin.txt "," r ", stdin); freopen (".. /stdout.txt "," W ", stdout); # endif int n, m; while (~ Scanf ("% d", & M, & N) {int T = m % (1 + n); If (! T) printf ("None \ n"); elseprintf ("% d \ n", T);} return 0 ;}