Test instructions: Gives the length of an array of n, giving H, indicating that it contains H 1, all its permutations
You can use Next_permutation.
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A - #defineforeach (I,c) for (__typeof (C.begin ()) i = C.begin (); I! = C.end (); ++i) - thetypedefLong LongLL; - Const intINF = (1<< -)-1; - Const intMod=1000000007; - Const intmaxn=100005; + - intP[MAXN]; + A intMain () { at intT; -scanf"%d",&T); - while(t--){ - - intn,h; -scanf"%d%d",&n,&h); in - for(intI=0; i<n;i++){ to if(i1; + Elsep[i]=0; - } the *Sort (p,p+n); $ Panax Notoginseng Do{ - for(intI=0; i<n;i++) printf ("%d", P[i]); theprintf"\ n"); +} while(Next_permutation (p,p+n)); A the if(T) printf ("\ n"); + } - return 0; $}View Code
UVa 729 The Hamming Distance problem "enumeration arrangement"