Blue Bridge Cup-with score

Source: Internet
Author: User

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

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.