1、从左边开始,找到一个满足左边小于自己的数a
2、从这个数a开始向右找,找到一个最小的比a打的数,两者交换
3、把从a开始向右的所有数用qsort从小到大排个序
[cpp]#include <iostream>
using namespace std;
void nextPermutation(int a[],int n);
int myCompare(const void *a,const void *b);
void exchange(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
void nextPermutation(int a[],int n)
{
int i;
for(i=n;i>0&&a[i-1]>a[i];i–);
if(i==0) {
for(i=1;i<=n;i++)
a[i]=i;
return;
}
int j,*min;
min=&a[i];
for(j=i+1;j<=n;j++) {
if(*min>a[j]&&a[j]>a[i-1])
min=&a[j];
}
exchange(a+i-1,min);
qsort(a+i,n-i+1,sizeof(int),myCompare);
}
int myCompare(const void *a,const void *b)
{
return *((int*)a)-*((int*)b);
}
int main()
{
int a[1024];
int n,k;
int N,i;
a[0]=2000;
scanf("%d",&N);
while(N–) {
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=0;i<k;i++)
nextPermutation(a,n);
for(i=1;i<=n-1;i++)
cout<<a[i]<<" ";
cout<<a[n]<<endl;
}
}
[/cpp]
1000MS正好AC
下面这个是用的STL的库函数 耍流氓
[cpp]#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main()
{
int a[1024];
int n,k;
int N;
scanf("%d",&N);
while(N–) {
scanf("%d%d",&n,&k);
int i;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
int *start=a+1;
int *end=a+n+1;
for(i=0;i<k;i++)
next_permutation(start,end);
for(i=1;i<=n-1;i++)
cout<<a[i]<<" ";
cout<<a[n]<<endl;
}
}
[/cpp]
If some one needs to be updated with latest technologies then he must be go to
see this web page and be up to date daily.
Some users browse for keywords like felching during keyword analysis.
Good response in return of this question with firm arguments
and telling everything about that.
A lot of people look for terms such as adult video when exploring online trends.
References:
Australian pokies payid git.juntekim.com
References:
Online pokies real money payid jobcop.uk
References:
Best instant payid pokies australia real money https://musixx.smart-und-nett.de/genevievegirar
References:
Australian online pokies payid https://becariosdigitales.com
Hi there, i read your blog from time to time and i own a similar
one and i was just wondering if you get a lot of spam
remarks? If so how do you reduce it, any plugin or
anything you can advise? I get so much lately it’s driving me insane so any assistance is very much appreciated.
References:
Best instant payid pokies australia real money https://dgwork.co.kr/blainec7581206
I’d like to thank you for the efforts you have put in writing this
site. I’m hoping to see the same high-grade
blog posts from you in the future as well. In fact, your creative writing abilities has motivated me to get my own,
personal blog now 😉
References:
Payid pokies instant withdrawal jobcop.uk
I’m impressed, I must say. Seldom do I come across
a blog that’s both equally educative and engaging, and let
me tell you, you have hit the nail on the head.
The problem is something too few people are speaking intelligently
about. I’m very happy I found this in my hunt for something relating to this.
I just could not depart your web site before suggesting that I
really enjoyed the standard information an individual supply in your visitors?
Is going to be back steadily to inspect new
posts
Just want to say your article is as amazing. The clarity on your put up is simply spectacular and
i could assume you are an expert in this subject.
Fine along with your permission allow me to
snatch your feed to stay up to date with forthcoming post.
Thanks 1,000,000 and please keep up the rewarding
work.
I really like looking through an article that will make men and women think.
Also, many thanks for permitting me to comment!
Hello are using WordPress for your blog platform? I’m new to the blog world
but I’m trying to get started and create my own. Do you need any html coding expertise to make your own blog?
Any help would be really appreciated!
When I initially left a comment I seem to have clicked on the -Notify me when new comments are added- checkbox and from now on every time
a comment is added I receive four emails with the same comment.
Perhaps there is an easy method you are able to remove
me from that service? Cheers!
Do you mind if I quote a few of your posts as long
as I provide credit and sources back to your site? My blog is in the very same niche as yours and my users would definitely benefit from some of the information you provide
here. Please let me know if this ok with you.
Many thanks!
Definitely believe that which you stated. Your favorite justification appeared to be
at the net the simplest factor to keep in mind of. I say to you, I definitely get
irked while folks think about concerns that they plainly do not recognise about.
You managed to hit the nail upon the highest and also defined out the entire thing with no need side-effects ,
people could take a signal. Will probably be
back to get more. Thank you
It’s not my first time to pay a quick visit this web site, i am visiting this web page dailly and get good facts from here everyday.
I could not resist commenting. Perfectly written!
References:
Lollybet Umsatzbedingungen http://www.google.me/url?q=https://lollybet.com.de/
References:
Lollybet Kundenservice http://n1.dime0523.cafe24.com/member/login.html?noMemberOrder=&returnUrl=http://lollybet.com.de
Excellent blog post. I absolutely love this site. Stick with it!
I quite like reading through a post that will
make men and women think. Also, thank you for permitting
me to comment!
Fascinating blog! Is your theme custom made or did you download
it from somewhere? A design like yours with a few simple adjustements would really make my
blog shine. Please let me know where you got your design. Appreciate it
Heya i am for the primary time here. I came
across this board and I to find It really helpful & it helped me out much.
I am hoping to provide something back and aid others like you aided me.
I don’t know whether it’s just me or if everybody else experiencing problems with your site.
It looks like some of the text in your content are running
off the screen. Can somebody else please comment and let me know if this is happening to them too?
This may be a issue with my internet browser because
I’ve had this happen previously. Appreciate it
If you would like to take a great deal from this piece of writing then you have to apply such techniques to your won website.
What’s Going down i am new to this, I stumbled upon this I have found It absolutely useful and it has helped me out loads.
I am hoping to give a contribution & aid other customers
like its aided me. Good job.
After I initially left a comment I seem to have clicked on the -Notify me
when new comments are added- checkbox and now
each time a comment is added I get four emails with the exact
same comment. There has to be an easy method you can remove me from that
service? Thanks!
It’s really a cool and helpful piece of info. I am happy that you simply shared
this useful info with us. Please keep us up to date like this.
Thank you for sharing.
References:
Cherry red casino https://tradelinx.co.uk/
References:
Grand falls casino http://www.cbl.health
References:
Super scratch programming adventure https://jobcop.uk
Pretty section of content. I just stumbled upon your weblog and in accession capital to
assert that I get actually enjoyed account your blog posts.
Anyway I’ll be subscribing to your augment and even I achievement you access consistently fast.
It’s not my first time to pay a quick visit this
web page, i am visiting this web site dailly and get good
facts from here all the time.
References:
How does betting odds work https://martdaarad.com/
References:
Meskwaki casino pacificllm.com
References:
Casinos en linea hirings.online
References:
G casino thanet http://www.jobindustrie.ma
References:
Casino splendido https://talenthubethiopia.com
Thanks for sharing your thoughts about bolly4u bolly4u.
Regards
References:
South coast casino https://meekook.com/
References:
Palms casino las vegas https://a2znaukri.com/employer/spielen-sie-casino-spiele-online-bei-instant-casino/
Why people still use to read news papers when in this technological world everything is presented
on web?
It’s remarkable for me to have a website, which is beneficial in favor of my experience.
thanks admin
Do you mind if I quote a few of your posts as long as
I provide credit and sources back to your weblog?
My blog site is in the very same area of interest as
yours and my users would genuinely benefit from some of the information you provide here.
Please let me know if this alright with you. Regards!
I’m gone to convey my little brother, that he should also
pay a quick visit this webpage on regular basis to obtain updated from latest information.