Full array
answer
As for this question, the beginning of thought is: FOR loop.
Piles of branching and looping results:
Results Output: 40% overrun time
suddenly tears ~~~
later remembered recursively
following code:
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
#include<ctime>
#include<algorithm>
using namespace std;
int t=1;
bool flag[10]={false};
long long a[10];
int n,check=0;
void print(){
for(int i=1;i<=n;i++){
cout<<a[i];
}
cout<<"\n";
}
void f(){
while(1){
for(int j=1;j<=n;j++){
check=0;
for(int i=1;i<=n;i++){
if(a[i]>n&&i!=1){
a[i]=1;
a[i-1]+=1;
}
if(a[i]==n){
check++;
}
}
}
print();
a[n]++;
if(check==n) break;
}
}
int main(){
for(int i=1;i<=10;i++){
a[i]=1;
flag[i]=false;
check=0;
}
cin>>n;
f();
return 0;
}
You can refer to the original site: JzxxOJ 4235