Small l time limit for D:4000Ms | Memory Limit:65535KB Difficulty:2
-
-
Describe
-
One day TC's Marina to find ACM small L play Three Kingdoms kill, but this will be small l busy mile, do not want to play with the marina, but also afraid of the marina, the small l to marina out a topic want to baffle marina (small l very D bar), there is a number n (0<n<10), write 1 to N of the whole arrangement, then marina a little embarrassed,,, Smart can you help Marina to the rescue?
-
-
Input
-
-
the first line enters a number n (0<n<10), which indicates that there are n sets of test data. The following n lines enter multiple sets of input data, each set of input data is an integer x (0<x<10)
-
-
Output
-
-
output all combinations in a specific order.
Specific order: The values in each combination are arranged from small to large, and the combinations are arranged in dictionary order.
-
-
Sample input
-
-
223
-
-
Sample output
-
-
1221123132213231312321
-
-
Source
-
-
Original
-
-
Uploaded by
Kapop
It's a water problem. next_permutation function to write. You can also use the DFS algorithm to write. The following is a next_permutation function to write.
#include <iostream> #include <algorithm>using namespace Std;int main () {int n,x,i,a[10];cin>>n;while (n--) { cin>>x; for (i=0;i<x;i++)//x==3 a[i]=i+1;//a[0]=1,a[1]=2,a[2]=3 does {for (i=0;i<x;i++) cout <<a[i]; cout<<endl; } while (Next_permutation (a,a+x));} return 0;}
D's Small L