`
ssun125
  • 浏览: 41218 次
文章分类
社区版块
存档分类
最新评论

HDU 1027 ( Ignatius and the Princess II )

 
阅读更多
Problem : 1027 ( Ignatius and the Princess II )     Judge Status : Accepted
RunId : 6278648    Language : C++    Author : ssun
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include "iostream"
#include "algorithm"

using namespace std;

int main(){
    int arr[1010];
    int i,m,n;
    while(cin>>n>>m){
        for(i=1; i<=n; i++){
            arr[i] = i;
        }
        i = 0;
        do{
            i++;
            if(i==m){
                for(int k=1; k<=n; k++){
                    cout<<arr[k];
                    if(k == n)
                        cout<<endl;
                    else
                        cout<<" ";
                }
            }
        }while(next_permutation(arr+n-7,arr+n+1));//由于m小于10000,所以从后面第八位开始排列
    
    }
    return 0;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics