[Loj 6695] son of weather

Title to find the law a model?

The meaning of problems

  https://loj.ac/problem/6695

answer

\ (N \ 5 \)

  By meter

\ (N \ 10 ^ 5 \)

  The optimal solution can not be found directly, so half the answer.
  Verifying the answer before the first \ (2 \) Personal into \ (1, m \) two positions with a difference between the two positions of the stack to maintain each adjacent to a new person each time, remove the smallest difference, divided equally into two halves, each stack thrown. If you remove the difference \ (\ le 3 \) it is determined that the answer is not feasible.
  Then consider two points on the boundary of the answer \ (R & lt \) , not difficult to find \ (R & lt \ Le with 3N \) , because there can ultimately be greater than \ (3 \) difference, otherwise the answer can be reduced.
  Time complexity \ (O (n-\ log n-) \) .

\ (N \ 10 ^ {18} \)

  Still half the answer \ (m \) , consider optimizing determination.
  Found hand count, the difference at most \ (2 ^ i \) and \ (. 1 + 2 ^ I \) ( \ (I \ in N \) ) are two, namely \ (2 \ log m \) species.
  Therefore, the accumulated number of occurrences in descending recursion and each difference, if the accumulated \ (n-\) swept to the difference \ (\ le 1 \) it is determined that the answer is not feasible.
  Time complexity \ (O (\ log ^ n-2) \) .

\ (N \ 10 ^ {1000} \)

  To find the law, but the practice may and solution to a problem loj not the same, is scb Great God Ben (guess?)
  We find that the inputs and outputs to exchange, it seems is a simple \ (\ text {dp} \ ) title: Let \ (f (i) \) represents the number of seats as \ (I \) many people can not sit up adjacent, then there is \ [f (i) = f (\ lfloor \ frac {i-3} {2 } \ rfloor) + f (i
-3- \ lfloor \ frac {i-3} {2} \ rfloor) +1 \]   i.e. select the most in the middle of a seat, the two seats adjacent to it can not be used, the remaining \ (i-3 \) seats is bisected into two halves, each half of a successor state.
  Then there $ \ (ANS = F (. 4-I) +2 \)
  i.e. above \ (\ text {dp} \ ) transferred every time the seat is in the middle section of one discharge, we finally, at both ends put two people beginning.
  Input entitled \ (ANS \) , output \ (I \) . Set \ (G \) is \ (F \) inverse function, because \ (ANS-2 = F (I-. 4) \) , so \ (G (ANS-2) = I-. 4 \) , i.e. \ (g (ans-2) + 4 = i \)

  Now only need to quickly find \ (G (the n-) \) ( \ (the n-ANS = \) ).
  The \ (f \) function to make a table, found the change very strange, did not seem to rule. The \ (g \) function to make a table, did not seem to rule.
  But the \ (g \) the difference between each adjacent two functions make the score table, find the difference values were \ [1,3,1,5,1,1,1,9,1,1,1, 1,1,1,1,17,1,1, \ cdots \]
  we find that the sequence is in full \ (1 \) sequence of the first \ (2 ^ 1 \) bits plus \ (2 ^ 1 \ ) , the section \ (2 ^ 2 \) bits plus \ (2 ^ 2 \) , the section \ (2 ^ 3 \) bits plus \ (2 ^ 3 \) ......
  Since this is \ (G \) of differential sequence, prepro \ (n-\) and that the item \ (G (n-) \) .
  And observe the law. The first \ (1 \) number of \ (2 ^ 0 \), The \ (2-3 \) number and for the \ (2 ^ 2 \) , the \ (4-7 \) number and for the \ (2 ^ 3 \) , the \ (8-15 \ ) number and for the \ (2 ^ 4 \) ......
  subscript values were tested and \ (2 \) exponential growth.
  If as a binary number and put, this number will not exceed \ (\ log_2 {10 ^ { 1000}} ≈3000 \) bits.
  Since last paragraph is not complete, we propose a single sum the last paragraph, and then the front \ (\ log_2 \) a whole section sums.
  Last paragraph before seeking \ (K \) number and: the first number is found in the section over a period of sum \ (1 + \) , the latter is the number of full \ (1 \) , so that when the count Recursive current and sweep segment, and the section from the plus \ (K \) a \ (1 \) is, before last paragraph \ (K \) number and.
  Seeking complete all sections of the front and: Let a total of \ (n \) segment,

Guess you like

Origin www.cnblogs.com/scx2015noip-as-php/p/loj6695.html