1 Star 0 Fork 0

向宇 / 初学之旅:2022大一秋

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
洛谷刷题66 P2524 Uim的情人节礼物·其之弐 519 Bytes
一键复制 编辑 原始数据 按行查看 历史
#include<bits/stdc++.h>
using namespace std;
long Compute(long x);
long n,x[20],minor,rankn;
int main(void)
{
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%1d",&x[i]);
for(int i=0;i<n;i++)
{
minor=0;
for(int j=i+1;j<n;j++)
{
if(x[j]<x[i]) minor++;
}
rankn+=minor*Compute(n-1-i);
}
cout<<rankn+1;
return 0;
}
long Compute(long x)
{
if(x==1) return 1;
else if(x>1) return x*Compute(x-1);
else return -1;
}
C
1
https://gitee.com/X_yugg1/learning-journey.git
git@gitee.com:X_yugg1/learning-journey.git
X_yugg1
learning-journey
初学之旅:2022大一秋
master

搜索帮助