求助,有问题
  • 板块学术版
  • 楼主lmrttx
  • 当前回复1
  • 已保存回复1
  • 发布时间2020/9/18 21:05
  • 上次更新2023/11/5 13:01:35
查看原帖
求助,有问题
344382
lmrttx楼主2020/9/18 21:05

这是洛谷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 ??? 什么意思??? 求助,谢谢!!!

2020/9/18 21:05
加载中...