Blue Bridge Cup with score

Source: Internet
Author: User

Come in a full line, then enumerate the +/and the position, the time complexity is probably, 9. *28



Previous questions with fractional time limit: 1.0s memory limit: 256.0MBDescriptive narrative of the problem

100 can be expressed as a fractional form: 100 = 3 + 69258/714.

Can also be expressed as: 100 = 82 + 3546/197.

Note features: With fractions, the digital 1~9 appear separately and appear only once (excluding 0).

Similar to this band fraction. 100 there are 11 kinds of notation.

Input format

Reads a positive integer N (n<1000*1000) from the standard input

Output format

The program outputs the number with a digital 1~9 that does not repeatedly make up all the seed numbers expressed with fractions.

Note: It is not required to output every representation, just how many representations are counted.

Example Input 1100 Example output 111 example input 2105 example output 26

#include <iostream> #include <map> #include <string> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <queue> #include <vector> #include <algorithm >using namespace Std;int box[9];int toint (int l,int r) {int i,ans;ans=0;for (i=l;i<=r;i++) ans=ans*10+box[i]; return ans;} int main () {int i,j,ans,a,b,c,x;cin>>x;ans=0;for (i=1;i<10;i++) box[i-1]=i;do{for (i=0;i<7;i++) {A=toint ( 0,i), if (a>=x) break;for (j= (9+i)/2;j<8;j++) {b=toint (i+1,j), C=toint (j+1,8), if (b%c==0) if (a+b/c==x) ans++;if (a +b/c>x) Break;}}} while (Next_permutation (box,box+9)); Cout<<ans;return 0;}


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.