Cherries Mesh:
Logic:
use Kruskal to find mst of different components, then suppose there are K component then we require k-1 connection of 2 to connect them. answer=sum of mst of min wt of diff component+(k-1)*2;
code:
https://shashankmishracoder.wordpress.com/2019/08/25/125/
Street Checkers
logic:
- number =2^p1*3^p2*5^p3......... 1.total number of factors=(p1+1)*(p2+1)*....
- total odd factors(X)=(p2+1)*()...
- total even factor=(p1+1)X-X=p1*X;
- diff=(p1-1)*X;
- if p1=0 -x>=-2 so 1 or prime number
- if p1=1 diff=0
- if p1=2 X<=2 so 4 or prime
- if p1=3 then only 8 is possible
calculate if number is prime from L to R(using segmented sieve) the use above conditions.
code:
https://shashankmishracoder.wordpress.com/2019/08/25/google-kickstart-2019round-e-street-checkers/