Rockethon2015 B Question Permutations rule + structure
Question: Find the m column of the maximum given formula value.
Idea: if we know how to make the n-1 arrangement of f (p) the largest, we can put n on both sides of (n-1) for the n arrangement of f (p) the largest. Because n is placed on both sides of (n-1), the value added is
1 + 2 +... + n, if not placed on both sides, (n-1) to n N placement, for I, if m <2 ^ (n-i-1 ),
Then I will be placed at the pos, or it will be placed at the end of the executable, that is, the last position. Because (I + 1) must be on the left of I, and later than (I + 1) must be on the left of I. For details, see the code:
/*************************************** * ****************** File name: b. cpp author: kereo create time: ******************************** * ************************/# include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Define deusing namespace std; typedef long ll; const int sigma_size = 26; const int N = 50 + 10; const int MAXN = 100000 + 50; const int inf = 0x3fffffff; const double eps = 1e-8; const int mod = 1000000000 + 7; # define L (x) (x <1) # define R (x) (x <1 | 1) # define PII pair
# Define mk (x, y) make_pair (x), (y) int n; ll m; int ans [N]; ll base [N]; int main () {base [0] = 1; for (int I = 1; I