Zoj1003 crashing balloon

Source: Internet
Author: User

Although it is a deep search, its ownCodeAlways wa...

I read some code online, basically the same way.

Worship ing...


/*************************************** **************************************** # Author: neo Fung # Email: neosfung@gmail.com # Last modified: # filename: zoj1003 crashing balloon. CPP # description: **************************************** **************************************/# ifdef _ msc_ver # define debug # DEFINE _ crt_secure_no_deprecate # endif # include <fstream> # include <stdio. h> # Include <iostream> # include <string. h> # include <string> # include <limits. h> # include <algorithm> # include <math. h> # include <numeric> # include <functional> # include <ctype. h> # define Max 101 using namespace STD; int flag1, flag2; void DFS (int x, int y, int N) {If (y = 1) {flag2 = 1; if (x = 1) flag1 = 1; // The first decomposition is smaller than the decimal number, so the larger number is decomposed (that is, flag1 is set to 1) if (n> 100 | flag1 = 1 & flag2 = 1) return; // recursive Exit: N exceeds 100, or both numbers are decomposed if (x % N = 0) DFS (x/N, Y, n + 1); // large numbers use the factor n if (Y % N = 0) DFS (X, y/n, n + 1); // use the factor n DFS (X, Y, n + 1) for a small number; // neither use the factor n} int main (void) {# ifdef debug freopen (".. /stdin.txt "," r ", stdin); freopen (".. /stdout.txt "," W ", stdout); # endif int A, B, T; while (~ Scanf ("% d", & A, & B) {if (a <B) {T = A; A = B; B = T ;} // make sure A> B flag1 = flag2 = 0; DFS (A, B, 2); // start searching from 2 // printf ("% d/N ", flag1, flag2); If (flag2 &&! Flag1) printf ("% d \ n", B); // only when the challenge succeeds, that is, the decimal part is successfully decomposed, else printf ("% d \ n", a);} 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.