HDU ACM 1517 A multiplication Game

Source: Internet
Author: User

Game problem.
Test instructions: 2 people play the game, starting from 1, take the logarithm to multiply, until more than a specified value n.
Analysis:
1, if input 2 ~ 9, because Stan is the initiator, so Stan win
2, if the input 10~18, because Ollie is, regardless of the first time Stan is what, Stan must be between 2 ~ 9, if Stan Times 2, then Ollie multiplied by 9, to 18, if Stan multiplied by 9, then Ollie Times greater than 1 of the number can be more than 10 ~ Any number in the 18. Ollie win
3, if the input is 19 ~ 162, then this range is Stan's winning state
4, if the input is 163 ~ 324, this is another Ollie of the winning state
5, the winning state is symmetrical!!!
So the outcome of the decision on N, if N is constantly in addition to 18 after the number of less than 18 m, if the 1 Then the hand wins.

#include <iostream>using namespace Std;int main () {double N;while (cin>>n) {while (n>18) n/=18;if (n<=9 ) puts ("Stan wins."); Else puts ("Ollie wins.");}    return 0;}

HDU ACM 1517 A multiplication Game

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.