T1 "Egyptian prime number sieve" "disjoint-set."
I thought of using on the test set and check the statistics Unicom block
However, how to connect and think only difference set $ O (n ^ 2) $ of
The number of prime numbers 1e6 looked inside 78498, I do not think
As long as the number of all prime factors of each merger
In fact, Egypt is thought sieve, to obtain each point with Egypt sieve prime factors, complexity (ln) $ smaller than the harmonic series $ O
Wire screen so you can play
int x=a[i]; while(x>1){
... x/=vis[x]; }
In short, the number 1 to the 2e9 quality factor for each of the number of at most 10, the sum of the quality factor index does not exceed 30
Enumeration quality factor may be pretreated in advance, eliminating $ O (\ sqrt {n}) $
[T2] FIG shaped upper press dp
D and n are found are relatively small
Defined bool f [i] [j] [s] a path length of i reaches the point j, the current state, the legality
Found that consideration transferred, no less than the state open, two-way search tips
F is defined as positive, defined as the inverse of g
dp transfer enumeration l, and the reaching point and state, fg were transferred to
When statistical enumeration state as long as the answer to what point and intermediate point
Note that respectively correspond to the length, tone for a long time. .