HDU 1525 Euclid's game)

Source: Internet
Author: User

Reprinted please indicate the source, thank youHttp://blog.csdn.net/ACM_cxlove? Viewmode = Contents
By --- cxlove

Give two numbers, A and B. Subtract the multiples of several bits from the large number, and the number will win if it is 0.

Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1525

Two numbers A and B always have a situation of B, A % B, which is inevitable. If a> = B & A <2 * B, then there is only one case, directly to B, A % B. Otherwise, there are multiple cases.

For A/B = 1, only B, A % B can be selected. If a/B> = 2, you can first select who will face the situation like B and A % B.

Obviously, players are smart enough. B. It is clear who wins and loses B. First-hand players must win in a/B> = 2.

 
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # include <vector> # include <string> # include <map> # define ll long # define n 1000000 # define INF 1 <20 using namespace STD; int main () {int A, B; while (scanf ("% d", & A, & B )! = EOF & A + B) {if (a <B) Swap (a, B); bool Stan = true; while (1) {If (B = 0 | A % B = 0 | A/B> = 2) break; int T = A; A = B; B = T-A; Stan =! Stan;} If (Stan) printf ("Stan wins \ n"); elseprintf ("Ollie wins \ n");} 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.