P2524 Uim的情人节礼物·其之弐

题目如下:

 思路:

1.  123 132 213 231 

从231开始往上还有三个顺序加上本身为4个

2.需要注意的是定义为char 因为没有输入空格

代码如下:

//321 312 231 213
//123 132 213 231 
#include<cstdio> 
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m,s=0;
    cin>>n;
    char a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    while(prev_permutation(a,a+n)){
    s++;
    }
    cout<<s+1; 
     
         
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/miao-xixixi/p/13369423.html