这是洛谷P2524 一个与康托展开有关的题目 以下是我的代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
int n1;
char x[110];
const int fac[10]={1,1,2,6,24,120,720,5040,40320,362880};
int contor(char x[],int n)
{
int ans=0;
for(int i=0;i<n;i++)
{
int smaller=0;
for(int j=i+1;j<n;j++)
{
if(x[i]>x[j])
smaller++;
}
ans+=smaller*fac[n-i-1];
}
return ans+1;
}
int mian()
{
scanf("%d%s",&n1,x);
cout<<contor(x,n1);
return 0;
}
为啥会 编译显示 ld返回1 ??? 什么意思??? 求助,谢谢!!!