[Training] Anhui network

Description

  Give you a tree with the right side, there \ (Q \) revision unilateral right side, for the first time before the amendment and after every change you need to answer how many trees there are paths to satisfy all sides on the right path gcd is \ (1 \) .

Solution

10~70pts

  Partition side, the right side of the center of gravity of decomposition of the quality factor, it will only decomposed \ (7 \) a qualitative factor. These \ (7 \) th prime factors like pressure, left subtree first sweep, the state provided for each point to the center of gravity of which is included gcd \ (7 \) a prime factors, each point into the corresponding state bucket. Then sweep right subtree, enumeration \ (2 ^ 7 \) answer state, the pairing state can be accumulated.
  FIG daisy can put a bare side of this partition card into \ (10 \) , passed through a turn of the new binary + \ (0 \) edge of a Japanese sentence can be done through Theory \ (30 \) points (I tune have the mentality of collapse and then deleted this ......).
  But the data really is a question of making people take the foot, did not turn a binary tree are running more than 800ms card after a \ (70 \) sub-range, but unfortunately I was too Shabi, leading to a small data WA, and had a \ (60 \ ) ......

100pts

  Such questions are generally gcd and related Mobius inversion.

Guess you like

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