Title Description
It can be expressed as a fractional form:3 + 69258/714.
It can also be expressed as:+ + 3546/197.
Note features: With fractions, the digital 1~9 appear only once (not including 0).
Similar to such a band fraction , There are a one - way notation.
Input
Reads a positive integer N (n<1000*1000) from the standard input
Output
The program outputs this number with a digital 1~9 not to be omitted to make up the total number of points expressed with fractions.
Note: No output is required for each representation, only how many representations are counted!
Input Example 1
100
Output Example 1
11
Input Example 2
105
Output Example 2
6
Analysis: If you think of the whole arrangement, better to do. Solve problems quickly with the full permutation function next_permutation (first,end) provided by STL
The code is as follows:
#include <iostream>#include<algorithm>using namespacestd;intlist[]={0,1,2,3,4,5,6,7,8,9};intFindintNintm);intMain () {intN; CIN>>N; intm=0, temp=N; Do{Temp=temp/Ten; M++; } while(temp!=0); cout<<find (N,M); return 0; }intFindintNintm) { intCount=0; Do{ //I is the number of bits of a for(intI=1; i<m;i++){ intA=0, b=0, c=0; for(intj=1; j<=i;j++) A=a*Ten+List[j]; intB_end= ((n-a) *list[9])%Ten; intk=i+1;//The starting bit of B//the terminating bit of B is asked while(b_end!=list[k]&&k<9) K++; if(k==9) Continue; //find the value of B for(intj=i+1; j<=k;j++) b=b*Ten+List[j]; //find the value of C for(intj=k+1; j<=9; j + +) C=c*Ten+List[j]; //Validation if(b%c==xx&& (a+b/c) = =N) Count++; } } while(Next_permutation (list+1, list+Ten)); returncount;}
Blue Bridge Cup-with score