Hdu2149 public sale, Bashi game

Source: Internet
Author: User

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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.