圆排列公式
圓排列公式:從n個元素中選r進(jìn)行圓排列。
例題: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 }
總結(jié)
- 上一篇: chrome离线安装包下载方法
- 下一篇: 简书 php三级联动,JS 实现三级联动