UVA 471-magic Numbers

Source: Internet
Author: User

Test instructions: Give a number n, ask how many groups are satisfied is S1/S2 =n, the number of calls to make up S1 and S2 is not duplicated.

Parse: enumeration, and then binary to determine whether the numbers are the same.

1#include <iostream>2#include <cstdio>3 #defineINF 98765432104 using namespacestd;5 6 BOOLJudgeLong LongN)7 {8     intCnt=0;9     intm;Ten      while(n) One     { Am=1<< (n%Ten);//expansion of each digit to 2^n -         if(cnt&m)//Find out if other bits have contributed 1 -             return false; thecnt|=m;//, add up all the numbers . -N/=Ten; -     } -     return true; + } -  + intMain () A { at     intT; -     Long Longn,s1,s2; -scanf"%d",&t); -      while(t--) -     { -scanf"%lld",&n); in          for(s2=1; s2<=inf;++S2) -         { tos1=n*S2; +             if(s1>INF) -                  Break; the                 if(Judge (S1) &&judge (S2)) *printf"%lld/%lld =%lld\n", s1,s2,n); $         }Panax Notoginseng         if(t) -cout<<Endl; the     } +     return 0; A}

UVA 471-magic Numbers

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.