圆排列公式


圆排列公式:从n个元素中选r进行圆排列。

在这里插入图片描述

例题:https://codeforc.es/contest/1433/problem/E

 1 #include<bits/stdc++.h>
 2 #define ll long long 
 3 #define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
 4 #define fi first
 5 #define se second
 6 #define pb push_back
 7 #define mp make_pair
 8 
 9 using namespace std;
10 const int mod=1e9+7;
11 const int maxn=1e4+6;
12 typedef long double ld;
13 typedef pair<int,int> pii;
14 typedef pair<ll,ll> pll;
15 int a[maxn];
16 int main()
17 {
18     int n;
19     cin>>n;
20     ll res=1;
21     for(int i=n/2+1;i<=n;i++)
22         res*=i;
23     for(int i=1;i<=n/2;i++)
24         res/=i;
25     for(int i=1;i<=n/2-1;i++)
26         res*=i*i;
27     res/=2;
28     cout<<res<<endl;
29 
30 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM