Description
100 may be represented in the form of mixed fractions: 69 258 + 3 = 100/714.
It can also be expressed as: 82 + 100 = 3546/197.
Note wherein: a mixed fraction, the numbers 1 to 9 appears once and only once, respectively (not including 0).
Mixed fraction like this, there are 11 100 notation.
It can also be expressed as: 82 + 100 = 3546/197.
Note wherein: a mixed fraction, the numbers 1 to 9 appears once and only once, respectively (not including 0).
Mixed fraction like this, there are 11 100 notation.
Input
From the standard input a positive integer N (N <1000 * 1000)
Output
With a digital program outputs the digital 1 ~ 9 will not be repeated without omission mixed fraction consisting of all the number of species represented.
Note: does not require the output of each said only statistics on the number representation!
Note: does not require the output of each said only statistics on the number representation!
Sample Input 1
100
Sample Output 1
11
Sample Input 2
105
Sample Output 2
6
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include <vector> 8 #include <queue> 9 #include <set> 10 #include <stack> 11 #include <map> 12 #include <sstream> 13 const int INF=0x3f3f3f3f; 14 typedef long long LL; 15 const int MOD = 1E9 + . 7 ; 16 const int MAXN = 1E7 + 10 ; . 17 the using namespace STD; 18 is . 19 int A [ 10 ]; // store full permutation sequence 20 is 21 is int main () 22 is { 23 is int n-; 24 Scanf ( " D% " , & n-); 25 for ( int I = 0 ; I < . 9 ; I ++) // initialization 26 A [I] = I + . 1 ; 27 int ANS = 0 ; 28 do { 29 int A = 0 ; // integer part 30 for ( int I = 0 ; I <= . 6 ; I ++) // integer part up to six 31 is { 32 A * = A 10 + A [I]; 33 is int B = 0 ; // molecular moiety 34 is int C = 0 ; // denominator portion 35 IF(= A> n-) 36 BREAK ; 37 [ for ( int J = I + . 1 ; J <= I + ( . 9 - (I + . 1 ) + . 1 ) / 2 ; J ++) // molecular moiety least the remaining digit half 38 is B = B * 10 + A [J]; 39 for ( int J = I + ( . 9 - (I + . 1 ) + . 1 ) / 2 + . 1 ; J < . 9 ; J ++) // remaining bits all to the denominator 40 C = * C 10 + A [J]; 41 is IF (B% C == 0 && A + B / C == n-) // understood numerator / denominator must be an integer 42 is ANS ++ ; 43 is for ( int J = I + ( . 9 - (I + . 1 ) + . 1 ) / 2 + . 1 ; J < . 8 ; J ++) // molecular moiety becomes long, denominator becomes short 44 is { 45 B = B * 10 + A [J]; 46 is C = cA [J] * POW ( 10 , . 9 - (J + . 1 )); 47 IF (B% C == 0&&a+b/c==n) 48 ans++; 49 } 50 } 51 }while(next_permutation(A,A+9)); 52 printf("%d\n",ans); 53 return 0; 54 }