E. Two Round Dances
E. Two Round Dances
題解:先從n個元素裡選擇n/2個,然後另一個圓也就確定了,對兩個圓進行圓排列,但可能會有重複的所以/2
圓排列公式:從n個元素中選r進行圓排列。
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int N = 5e3+10;
const int inf = 0x7f7f7f7f;
ll fun(ll n){
ll sum = 1;
for(ll i = 1;i <= n;i++){
sum = sum*i;
}
return sum;
}
int main(){
// srand((unsigned)time(0));
/*
int n;cin >> n;
for(int i = 1;i <= n;i++){
a[i] = i;
}
fun1(n);
int ans = 1;
do{
if(fun(n)){
ans++;
fun1(n);
}
}while(next_permutation(a+1,a+1+n));
cout<<ans<<endl;
*/
ll n;cin >> n;
ll ans = 1,x = 1;
for(ll i = n/2+1;i <= n;i++){
ans = ans*i;
}
for(ll i = 1;i <= n/2;i++){
x = x*i;
}
ans /= x;
ans = ans*fun(n/2-1)*fun(n/2-1);
ans /= 2;
cout<<ans<<endl;
return 0;
}
/*
2 1
3 1
4 3
5 12
6 60
*/
相關文章
- Educational Codeforces Round 98 (Rated for Div. 2) E. Two Editorials 細節題
- Public Easy Round #2 E. 2048
- Codeforces Global Round 19 E. Best PairAI
- Educational Codeforces Round 19 E. Array Queries
- CodeForces 1883G1 Dances (Easy version)
- E. Cells Arrangement
- E. Chain ReactionAIReact
- E. Expected Power
- E. Level Up
- E. Not a Nim Problem
- E. Boring Segments
- E. Wooden GameGAM
- E. Final Countdown
- E. Iva & Pav
- E. Disrupting Communications
- E. Block SequenceBloC
- E. Data Structures FanStruct
- coca after two months vs in two months
- E. Increasing Subsequences__2
- E. We Need More Bosses
- E. C+K+S
- E. 我要打 k 個
- Two Pirates - 2
- Two Pointer Method
- Leetcode 231 Power of TwoLeetCode
- Leetcode 1 two sumLeetCode
- Merge Two Sorted List
- Tokitsukaze and Two Colorful Tapes
- LeetCode | 1 Two SumLeetCode
- 11.23 Two Different Worlds
- F - Two Sequence Queries
- CodeForces 145 E. Lucky Queries(線段樹)
- GJ Round
- Leetcode 29 Divide Two IntegersLeetCodeIDE
- TWO NODES(HDU-4587)
- LeetCode 2 Add Two NumbersLeetCode
- LeetCode-1 Two SumLeetCode
- [LeetCode]1.Two SumLeetCode