poj_2505 A Multiplication Game (game, Range)

Source: Internet
Author: User

Please point me in the question.
The following:
This question is the first question to multiply, considering who can be greater than or equal to n first. I don't think it's easy to find a balance like the Nim game for this kind of topic. In terms of winning and losing, we are turning into a problem to find the scope that everyone will be able to reach. First, for the initiator, 2~9 for the winning interval, regardless of the tempo, the minimum value that can be reached is 18, so the winning range is 10~18. Then and so on, each time in the consideration of the threshold value of each person is to hope that they can be bigger, and the opponent is the hope of smaller, two people to consider separately, so according to their own every time by 9, the opponent to consider the critical interval.
Therefore, the following results are consistent with the conclusion:
1~9->stan;
10~18=2*9->ollie;
19~162=9*2*9->stan;
163~324=2*9*2*9->ollie;
...
Code implementation:

#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#define LL Long Longusing namespace STD; LL N; LL range;intMain () { while(Cin>>n) {range =1;intFlag =1; while(Range < N) {if(flag) {Range *=9; Flag =0; }Else{Range *=2; Flag =1; }        }if(!flag) {cout<<"Stan wins."<<endl; }Else{cout<<"Ollie wins."<<endl; }    }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

poj_2505 A Multiplication Game (game, Range)

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.