first, the full line source code: #include<cstdio>#include<algorithm>//contains "Next_permutation". using namespacestd;intn,i[1001];intMain () {scanf ("%d", &n);//the full arrangement of the output 1~n. for(intA=1; a<=n;a++)//The output itself is first, and the array is assigned the value. {printf ("%d", a); I[a]=A; } printf ("\ n"); while(Next_permutation (i+1, i+n+1))//the dictionary output array designator is the other arrangement of 1~n. { for(intA=1; a<=n;a++) printf ("%d", I[a]); printf ("\ n"); } return 0;} Second, priority queue source code: #include<cstdio>#include<queue>//contains "Priority_queue". using namespacestd;intN,ans (0);p Riority_queue<int,vector<int>,greater<int> > i;//this is from small to large order, from large to small for less. intMain () {scanf ("%d",&N); for(intA=1; a<=n;a++) { intT; scanf ("%d",&6); I.push (t); } for(intA=1; a<n;a++) { intT=i.top ();//take the top element. I.pop ();//go to the top element. t+=I.top (); I.pop (); Ans+=T; I.push (t); //add elements. } printf ("%d", ans); return 0;}
STL (c + +)