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