标题: 排列序数
X星系的某次考古活动发现了史前智能痕迹。
这是一些用来计数的符号,经过分析它的计数规律如下:
(为了表示方便,我们把这些奇怪的符号用a~q代替)
abcdefghijklmnopq 表示0
abcdefghijklmnoqp 表示1
abcdefghijklmnpoq 表示2
abcdefghijklmnpqo 表示3
abcdefghijklmnqop 表示4
abcdefghijklmnqpo 表示5
abcdefghijklmonpq 表示6
abcdefghijklmonqp 表示7
.....
在一处石头上刻的符号是:
bckfqlajhemgiodnp
请你计算出它表示的数字是多少?
请提交该整数,不要填写任何多余的内容,比如说明或注释。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <math.h>
using namespace std;
long long jc( long long x ) {
if ( x==1 || x==0 ) return 1;
else return x*jc( x-1 ) ;
}
int main()
{
long long ans = 0 ;
char line[30] = "bckfqlajhemgiodnp";
line[17] = 0 ;
int len = strlen( line ) ;
for ( int i=0; i<len; i++ ){
long long s = jc( len-1-i ) ;
int cnt = 0 ;
for ( int j=i+1; j<len; j++ ) {
if ( line[j]<line[i] ) ++cnt;
}
ans += cnt*s;
}
cout<<ans<<endl;
return 0;
}