Super Portal:
http://acm.hdu.edu.cn/showproblem.php?pid=2200
Main topic:
Eddy is a acmer, he not only like to do ACM problem, but also for each of the ranklist in the number of AC has a certain research, he is bored often on the paper on the ranklist of the number of each person's AC topic, and then select a part of the person (or all) Comparing the number of AC into two groups, he wanted to make the minimum AC number in the first group greater than the maximum AC number in the second group, but that would be a lot of things, smart you know how many of these things?
Special note: For the sake of simplification, we assume that the number of extracts under the excerpt is N, and that the number of AC for each person is not equal and the final result is within a 64-bit integer range.
Gee, this problem is simple, I will not translate, directly copied over ...
Topic Analysis:
The law of Shining ... But I've been looking for a long time ... = = Too much water ...
And then finally figured out a way
Suppose N =4
If 2 is the first group of the smallest, that must be 2 below in the second group, 2 above in the first group, and, can appear, can not appear, so the case for the first group * The second group (2^2) * (2^1-1) here minus 1 is because the second group cannot be completely empty
So if 2 is the first group the smallest case is (2^2) * (2^1-1)
Similarly, if 3 is the first group, the smallest case is (2^1) * (2^2-1)
Similarly, if 4 is the first group, the smallest case is (2^0) * (2^3-1)
See the rules, and then organize, combined with geometric series formula, the final formula is f (n) = 1+ (n-2) * 2^ (n-1)
The code is good to write:
#include <iostream>
using namespace std;
int main ()
{
int i;
int n;
__int64 sum;
while (scanf ("%d", &n)! = EOF)
{
sum = 1;
sum<<=n-1;
Sum *= (n-2);
sum + = 1;
printf ("%i64d\n", sum);
}
return 0;
}