HDU 2149 public sale (classic game theory)

Source: Internet
Author: User

Public Sale
Problem description does not want to, but the reality is always a reality. Lele never escaped the fate of dropping out of school because he did not receive a scholarship. Now he is waiting for his farmland career like farmjohn.

Lele heard that there was a special auction on the street, and the auction of items was just a 20-acre field. So Lele took all his savings and rushed to the auction.

Later, we found that the auction only lasted for Lele and Yueyue.

Lele knew the auction rule was as follows: the reserve price was 0 at the beginning, and two people started to raise the price in turn, but each price increase was within 1 ~ Between N, when the price is greater than or equal to the cost of the field m, the organizer will sell the field to the price caller.

Although Lele and Yueyue cannot take the test, they are very proficient in the auction, and both of them really want this field. Therefore, each time they choose the most favorable way to increase their prices.

Because the Lele Lexicographic Order is higher than Yueyue, each time Lele starts to raise the price. Excuse me, when I first raise the price,
How much does Lele need to make sure they can buy this land?
 
Input this question contains multiple groups of tests. Please process it until the end of the file (EOF ). Each group of tests occupies one row.
Each group of tests contains two integers, M and N (for meanings, see the topic description, 0 <n, m <1100)
 
For each group of data, output the price that Lele can add for the first time in the ascending order of a row. The two data are separated by spaces.
If Lele cannot buy the land at whatever bid he made for the first time, it will output "NONE ".
 
Sample Input
4 23 23 5
 
Sample output
1none3 4 5
 
Authorlinle
Sourceacm Program Design final examination-(3 tutorial 417)


Solution:

This question applies to the core idea of the classic game theory, that is, a total of M. Each time the value range is [1, N]. If two people are playing, you should take one, i'll get n, and you get 2, and I'll get a N-1 ....... the sum of N + 1 is always the sum of N + 1 in each round. Therefore, we can find the remainder of N + 1. This idea is used. Of course, you can also use the SG function to extract the mandatory and mandatory states.


Solution code:

#include <iostream>#include <cstdio>#include <vector>using namespace std;int n,m;void solve(){    if(n>=m){        printf("%d",m);        for(int i=m+1;i<=n;i++) printf(" %d",i);        printf("\n");    }else{        if(m%(n+1)==0) printf("none\n");        else printf("%d\n",m%(n+1));    }}int main(){    while(scanf("%d%d",&m,&n)!=EOF){        solve();    }    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.