https://www.cnblogs.com/kittyamin/p/5014947.html
class Solution {
public:
/**
* @param A: An array of integers
* @return: A long integer
*/
long long permutationIndex(vector<int> &A) {
// write your code here
long long index = 0;
for(int i = 0; i < A.size(); i++){
int count = 0;
for(int j = i + 1; j < A.size(); j++){
if(A[j] < A[i]) count++;
}
long long factor = 1;
if(count){
int n = A.size() - i - 1;
cout<<n<<endl;
while(n > 0){
factor *= n--;
}
}
index += count * factor;
}
return index + 1;
}
};