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