2 条题解
-
0
使用康托展开来解,讨论里有解释
#include<stdio.h>
int main(){
int n,x;
char a[13];
scanf("%d",&n);
while(n--){
long long sum=0;
scanf("%s",a);
for(int i=0;i<12;i++){
x=0;
long long b=1;
for(int j=i+1;j<12;j++){
if(a[i]>a[j]){
x++;}
}
for(int z=1;z<=12-i-1;z++){
b=b*z;
}
sum=sum+x*b;
}
printf("%lld\n",sum+1);
}
return 0;
}
信息
- ID
- 174
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 3
- 标签
- (无)
- 递交数
- 234
- 已通过
- 117
- 上传者