CodeForces - 1433E 圆桌排序 组合数学

71 篇文章 1 订阅
8 篇文章 0 订阅

题目

在这里插入图片描述

题解思路

高中的圆桌排序,早就忘光了。
在这里插入图片描述
N个人选择一半进行组合,C(n,n/2) 因为可以交换结果还要除以2,然后再乘上两边的圆桌排序数即可。

AC代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

const  int  INF =  0x3f3f3f3f;

struct bian
{
    double w;
    int z;
    bool operator < (const bian &other) const
    {
        return w > other.w;
    }
};
int read() {
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}
long long ans = 1;
int n;

int main ()
{
    ios::sync_with_stdio(false);
    cin>>n;
    long long t1 = 1 ;
    long long t2 = 1;
    for (int i = 1 ; i <= n/2-1; i++ )
    {
        t1*=i;
    }
    for (int i = n/2 + 1 ; i <= n ; i++ )
    {
        ans*=i;
    }
    ans = (ans * t1 )/(n);
    cout<<ans<<"\n";
    return 0 ;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值