#P2316. [HNOI2005] 分形

    ID: 1285 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2005并查集各省省选湖南前缀和

[HNOI2005] 分形

Description

A fractal has a fractional dimension, between 22 and 33. A complete fractal picture often has a bounded area and an infinite perimeter. To explore the secrets of fractals, King persistently conducts an unconventional study.

He first studies a simple fractal: In the plane, there is a circle of radius R0R_0 (R0=105R_0 = 10^5) centered at the origin. It is externally tangent to several circles of radius R1R_1. Each circle of radius R1R_1 is externally tangent to several circles of radius R2R_2, …, and each circle of radius RiR_i is externally tangent to several circles of radius Ri+1R_{i+1}. Any two circles do not intersect, do not overlap, are not contained one in another, and are not internally tangent. A circle of radius RiR_i can only be externally tangent to circles of radius Ri1R_{i-1} or Ri+1R_{i+1}, and for i>0i > 0 it is externally tangent to exactly one circle of radius Ri1R_{i-1}.

As a foundation, he first studies a finite-layer simple fractal, that is, an (n+1)(n + 1)-layer fractal composed only of circles with radii R0R_0 through RnR_n. Figure 1 shows a 55-layer simple fractal. Since there are only finitely many layers, the boundary length is finite.

On the boundary, King identifies several pairs of points (Pi,Qi)(P_i, Q_i) related to the properties of the fractal picture. From PiP_i to QiQ_i, what is the length of the shortest smooth path (see the bold curve in Figure 1).

A smooth path means: at a common tangent point of two circles, when the path turns, its tangent direction remains unchanged. In Figure 2, the two bold paths on the left are smooth, while the bold path on the right is not smooth.

Input Format

The first line contains 33 integers n,m,tn, m, t. Here mm is the number of circles (and the circles are numbered 11 through mm), and tt is the number of special point pairs.

The second line contains nn positive integers R1R_1 through RnR_n.

Each of the next mm lines describes a circle. Each line contains 44 numbers Xi,Yi,Si,FiX_i, Y_i, S_i, F_i. (Xi,Yi)(X_i, Y_i) is the center of circle ii. The radius of circle ii is RSiR_{S_i}. The index of the larger circle tangent to circle ii is FiF_i. XiX_i and YiY_i may be real numbers.

Each of the next tt lines describes a special pair of points. Each line contains 44 numbers Pi,tW,Pi,tA,Qi,tW,Qi,tAP_{i,tW}, P_{i,tA}, Q_{i,tW}, Q_{i,tA}, which specify the locations of a special pair (Pi,Qi)(P_i, Q_i):

  • Pi,tWP_{i,tW} means point PiP_i lies on circle Pi,tWP_{i,tW}, and with the center of this circle as the origin, its argument (angle) is Pi,tAP_{i,tA}.
  • Qi,tWQ_{i,tW} means point QiQ_i lies on circle Qi,tWQ_{i,tW}, and with the center of this circle as the origin, its argument (angle) is Qi,tAQ_{i,tA}.

Output Format

For each special pair, output one line containing one integer, which is the shortest length divided by π\pi, rounded to the nearest integer.

1 3 3
50000
0 0 0 0
150000 0 1 1
0 150000 1 1
3 5.497787 	  2 2.356194
3 1.570796 	  2 0.0
3 0.0         2 1.570796

175000
150000
200000

Hint

For 50%50\% of the testdata:

  • m300m \le 300.
  • t1000t \le 1000.

For 100%100\% of the testdata:

  • 1n<m30001 \le n < m \le 3000.
  • 1t1051 \le t \le 10^5.
  • 2Rn<Rn1<<R1<R02 \le R_n < R_{n-1} < \ldots < R_1 < R_0.
  • Ri1Ri2R_{i-1} - R_i \ge 2.
  • R0=105R_0 = 10^5.
  • S0=1S_0 = -1.
  • X1=Y1=F1=S1=0X_1 = Y_1 = F_1 = S_1 = 0.
  • 3×108Xi,Yi3×108-3 \times 10^8 \le X_i, Y_i \le 3 \times 10^8.
  • 0Sin0 \le S_i \le n.
  • 1Fim1 \le F_i \le m.
  • FiiF_i \ne i.
  • SFi=Si1S_{F_i} = S_i - 1.
  • 1Pi,tW,Qi,tWm1 \le P_{i,tW}, Q_{i,tW} \le m.
  • Pi,tWQi,tWP_{i,tW} \ne Q_{i,tW}.
  • 0Pi,tA,Qi,tA<2π0 \le P_{i,tA}, Q_{i,tA} < 2\pi.
  • Any two circles are either externally tangent or disjoint.
  • All special points are not points of tangency.
  • Each circle is externally tangent to at most 1010 circles.
  • All real numbers have at most 66 decimal places.

Translated by ChatGPT 5