AGC032F One Third

A very strange question. I saw no way to start. Probability expect good question.


To an area of \ (1 \) circle passes through the center randomized web corner cut diameter \ (n-\) times, the definition of \ (F (X) = \ min | S - \ FRAC {1} {. 3} | \) , wherein \ (S \) is the contiguous block area. Seeking \ (f (x) \) expectations.

Currently we saw the two approaches.

Transformation first began are the same.

Because the answer is a continuous segment, and only related to the election of two vectors. Consider equation (area where the mold is calculated answer \ (1 \) ):

\[ \min \left\{|x - y \pm \frac{1}{3}|\right\} \]

\ (\ pm \) that is complementary to the two blocks are counted again. Thus a cut through the diameter can be directly used as a vector starting from the center. Similar unit vector in the complex plane.

We put back \ (- y \ pm \ frac {1} {3} \) proposed, that is, \ (y \) multiplied by a unit root of the three powers.

Therefore, it is better to each vector becomes \ (\ left \ {V, V \ Times \ ^ omega_3. 1, V \ Times \ omega_3 ^ 2 \ right \} \) , then find \ (x - y \) argument mode \ (\ frac {4 \ pi } {3} \) minimum.

Clearly there will be problems, because when multiplied by the same unit root when the answer is false, the original formula becomes \ (| the X-- the y-| \) , but the unit root is not the same row, so we extended the vector staining.

For example, \ (\ left [V, V \ Times \ omega_3 ^. 1, V \ Times \ omega_3 ^ 2 \ right] \) , respectively correspond to \ (\ left [\ texttt { red}, \ texttt {green}, \ {} Blue texttt \ right] \) (the RGB).

Then the problem and minimize the difference between the minimum amplitude flop angle.

Obviously the answer is less than \ (\ FRAC. 1 {{}}. 3 \) , and no other vector (i.e., taken only greedy adjacent to the contribution of the answers) between vectors Leis

Obviously, if a vector is selected as a reference unit circle divided into three parts it may be obtained by replacing a color of each other, so long as the operator \ (\ left [0, \ frac {1} {3} \ right) \) It can be.

Becomes a problem, the left red, green right, length \ (\ FRAC. 1 {{}}. 3 \) , any intermediate color spread \ (n - 1 \) point, \ (n-\) th heterochromatic segments the difference between the minimum desired length.


First come to a conclusion:

Length \ (1 \) , into \ (n-\) segments, the minimum length is desirably \ (\ FRAC {n-1} {2} ^ \) .

Prove it simple.

Consider computing \ (P \ left (\ min = x \ right) x \) integral, i.e. \ (P \ left (\ min \ geq x \ right) \) points. (In front of that I would not count \ (P \) , I counted out QAQ is wrong)

Consider \ (P \ left (\ min \ geq the X-\ right) \) , we will lose every paragraph \ (the X-\) , the rest pick, then \ (P \ left (\ min \ geq x \ right) = \ left (1 - nx \ right ) ^ {n-1} \)

Integral what you can prove.

There are two ways below

Direct the combined method

Determined easily \ (K \) minimum desired number of heterochromatic segments: \ (\ FRAC. 1 {{}}. 3 \ Times \ {n-FRAC {K}} \ Times \ FRAC. 1} {2} {K ^ = \ frac {1} {3nk} \)

So long as the calculated \ (k \) probability to a heterochromatic segments.

As long as we have a DP (k \) \ a heterochromatic segments, the first color is red for the last color green probability. Direct \ (dp \) a bit slow, which can be directly enumerate the number of combinations where the color has changed, so you can direct the probability of two different colors are adjacent to DP. As long as what color a next enumeration, \ (O \ left (n-\ right) \) to complete the calculation.

Clearly the answer can enumerate \ (k \) , multiplied by the probability of the count and expect to get.

Probabilistic methods

Segment length obtained considering ascending sort, if the minimum heterochromatic segments are \ (K \) is small, then the previous \ (k - 1 \) th are the same color.

Expansion at the above conclusion, we enumerate the first \ (k \) small. Now to get the first \ (k \) small length desired. Also consider losing some, available recursive formula:

\[E_k = \frac{1 - \sum_{i=1}^{k-1} \left(n - i + 1\right) E_i}{k^2} + \sum_{i=1}^{k-1} E_i\]

By hand count the first few, coupled with speculation and induction, you can get

\[E_k = \frac{1}{n} \sum_{i=1}^{k} \frac{1}{n - i + 1}\]

Now count \ (P \ left (\ min = k \ right) \) , but multiplied by the \ (E_k \) equation somewhat inelegant.

Therefore, change operator \ (P \ left (\ min \ GEQ K \ right) \) , then \ (\ min \ geq k \ ) Contribution up \ (\ frac {1} { n} \ times \ frac {1 n-{} - K +. 1} \) .

Obviously the answer to this sum unchanged. And \ (P \ left (\ min \ geq k \ right) \) is also very good count. Because at least \ (k - 1 \) segments are identical. Although it seems there are many segments end to end, so that the operator such that the probability of inter-related cancer look, but calmly can be found, for end to end splicing \ (L \) segments, it \ (L + 1 \) point the probability of all the same color as \ (\ left (\ FRAC {1} {3} \ right) ^ {L} \) , because the left-most point to determine whether or no impact on the answer.

Nonsense so much, in fact, \ (P \ left (\ min \ geq k \ right) = \ left (\ frac {1} {3} \ right) ^ {k - 1} \)

The answer is

\[ \begin{align*} E & = \frac{1}{3} \sum_{i=1}^{n} P(i) E_i \\ & = \frac{1}{n} \sum_{i=1}^{n} \frac{1}{3^{i} \left(n - i + 1\right)} \end{align*} \]

Be apparent \ (O \ left (n \ right) \) is calculated.

The code is simple, a very good question. Can be extended to \ (\ frac {1} { k} \)

#include <bits/stdc++.h>

const int mod = 1000000007;
const int inv3 = (mod + 1) / 3;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int fastpow(int a, int b, int res = 1) {
    for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
    return res;
}

const int MAXN = 1000010;
int inv[MAXN], n;
int main() {
    std::ios_base::sync_with_stdio(false), std::cin.tie(0);
    std::cin >> n;
    *inv = inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = mul(inv[mod % i], mod - mod / i);
    int ans = 0, now = 1;
    for (int i = 1; i <= n; ++i) {
        now = mul(now, inv3);
        reduce(ans += mul(inv[n - i + 1], now) - mod);
    }
    std::cout << fastpow(n, mod - 2, ans) << '\n';
    return 0;
}

If there is an error, please leave a message formula

Thank @ccosi @ pig had a go article

Guess you like

Origin www.cnblogs.com/daklqw/p/11714581.html