2019.10.12 problem solution

A. plank

label:

Prime factors specific root sign 筛法

answer:

Can be obtained by the similar triangles:

$ ans=8*\sum_{i=1}^{n-1}[i*i(mod)n==0] $

Root prime factors to screen out

 

B. cleaning

label:

Dp + list

Correct answer:

A violence can be a question, but the solution is not hard to think positive

The most violent Dp formula: $ f [i] = min {f [j] + cnt (j + 1, i) ^ 2} $

If j i-1 from the enumeration, we found that when cnt number to more than sqrt (f [i]) after the answer must not contribute

Consider maintaining a list with each number as of the end position i appear to ensure that the complexity of $ O (nsqrt (n)) $

 

Guess you like

Origin www.cnblogs.com/AthosD/p/11664731.html