Ultraviolet A Problem 847 a multiplication game (multiplication game)

Source: Internet
Author: User
Tags dot net
// A multiplication game (multiplication game) // PC/Ultraviolet IDs: 110505/847, popularity: A, success rate: high level: 3 // verdict: accepted // submission date: 2011-05-29 // UV Run Time: 0.012 S // copyright (c) 2011, Qiu. Metaphysis # Yeah dot net // assume that the final number is 162. To prevent the other party from getting a number greater than or equal to 162, one Party should try to make the number not greater than 162 // 9 = 18. If the number is greater than or equal to 18, the other party can multiply the number by 9 to be greater than or equal to 162, one Party should try to multiply the number // to get a number greater than or equal to 9, because in this way, no matter which multiplier is selected by the other party, the product will eventually be greater than or equal to 18, because 9 // 9 = 1, that is, whoever takes the ride first will win. // For the given number N, if Stan reaches the number n first, it is a victory and returns to the previous step. If Stan reaches N/9 first, // fails, continue to the previous step. If Stan reaches N/9/2 first, win the game and use recursion to solve the problem. # Include <iostream> # include <cmath> using namespace STD; void ones (INT number, bool win) {If (number <= 9 & Win) {cout <"Stan wins. "<Endl; return;} If (number <= 2 &&! Win) {cout <"Ollie wins." <Endl; return;} If (WIN) ones (Ceil (number/9.0 ),! Win); elseones (Ceil (number/2.0 ),! Win);} int main (int ac, char * AV []) {int number; while (CIN> Number) ones (number, true); 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.