Problem descriptioneddy is an acmer. He not only enjoys ACM, but also studies the number of AC for each person in the ranklist, when he is bored, he often extracts the number of AC questions of each person on the ranklist on paper, and then selects some (or all) people from them to divide them into two groups for comparison based on the number of AC questions, he wants to make the minimum AC number in the first group greater than the maximum AC number in the second group, but there will be many such cases. Do you know how many such cases are there?
Note: to simplify the problem, we assume that the number of people in the excerpt is N, and the number of each person's AC is not equal. The final result is within the 64-bit integer range.
Input contains multiple groups of data. Each group contains an integer N, indicating the total number of extracted data from the ranklist.
Output: for each instance, the total number of solutions that meet the requirements is output. Each output occupies one row.
Sample input24
Sample output117
Idea: assume there are n numbers, from which M is CNM,
The M number must meet the conditions as long as the Plug board can be arranged from 1 to M.
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <string> 5 #include <iomanip> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 #include <map>10 using namespace std;11 long long cal(long long n, long long x){12 long long sum = 1;13 for(int i = 1; i <= x; i++){14 sum = sum*(n-i+1)/i;15 }16 return sum;17 }18 int main(){19 long long N, sum;20 while(cin>>N){21 sum = 0;22 for(long long i = 2; i <= N; i++){23 sum += (i-1)*cal(N, i);24 }25 cout<<sum<<endl;26 }27 return 0;28 }