Zoj1003 crashing balloon

Source: Internet
Author: User

The focus of the question in question solution is to clearly analyze the rules for winning or losing.

Use two bool variables to indicate whether the two are telling the truth, DFS. If B is telling the truth and A is not telling the truth, B wins, and the rest are a wins.


# Include <cstdio> # include <algorithm> # include <iostream> using namespace STD; int n, m, F1, F2; void DFS (int A, int B, int num) {if (a = 1 & B = 1) // One solution is that both parties tell the truth. Only when both are true can a be confirmed to be honest. {F1 = F2 = 1; return;} If (B = 1) f2 = 1; // B tell the truth while (Num> 1) {if (a % num = 0) DFS (A/num, B, num-1 ); if (B % num = 0) DFS (a, B/num, num-1); num -- ;}} int main () {While (~ Scanf ("% d", & N, & M) {If (M> N) Swap (m, n); F1 = F2 = 0; DFS (n, m, 100); If (! F1 & F2) printf ("% d \ n", m); else printf ("% d \ n", n);} return 0 ;}


Zoj1003 crashing balloon

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.