圓排列公式


圓排列公式:從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