E. Two Round Dances (round arrangement problem)

Topic portal

Question: There are n people. Make sure that n is an even number. These n people stand in 2 circles at a time (no difference). Each circle has exactly n/2 people. Ask how many kinds of standing do you have.

Tip: 1234 and 2341 belong to the same kind of station method.

Idea: We first choose the people in the first circle, that is, choose n/2 people out of n people, and the people in the second circle are fixed, and then the standing method of each circle is a circle arrangement of n/2 people, that is Divide the total arrangement by the number of people. Because there is no difference between the two circles, 12, 34 and 34, 12 are equivalent, and the final count of the number of plans will do.

Code:

#include<bits/stdc++.h>
#define endl '\n'
#define null NULL
#define ls p<<1
#define rs p<<1|1
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define int long long
#define pii pair<int,int>
#define ull unsigned long long
#define pdd pair<double,double>
#define lowbit(x) x&-x
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
char *fs,*ft,buf[1<<20];
#define gc() (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<20,stdin),fs==ft))?0:*fs++;
inline int read()
{
    
    
    int x=0,f=1;
    char ch=gc();
    while(ch<'0'||ch>'9')
    {
    
    
        if(ch=='-')
            f=-1;
        ch=gc();
    }
    while(ch>='0'&&ch<='9')
    {
    
    
        x=x*10+ch-'0';
        ch=gc();
    }
    return x*f;
}
using namespace std;
const int N=3e5+1000;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const double eps=1e-6;
const double PI=acos(-1);

signed main()
{
    
    
	int n;
	cin>>n;
	int res=1;
	for(int i=n/2+1;i<=n;i++)
        res*=i;
    for(int i=1;i<=n/2;i++)
        res/=i;
    for(int i=1;i<=n/2-1;i++)
        res*=i*i;
    res/=2;
    cout<<res<<endl;

}

Guess you like

Origin blog.csdn.net/Joker_He/article/details/109196881