Help! Query on Tree — Codechef

Правка en1, от mkitkat, 2020-02-01 12:45:09

I can't understand the solutions of Query on trees https://www.codechef.com/COMA2020/problems/QUERYT . Help me with the concept and Solution.

Question: You are given a tree with N nodes and N−1 edges. The nodes are numbered from 1 to N and the tree is rooted at 1.

Every node has a value associated with it.

If we consider the simple path between two nodes u and v , then a node in this path is called special if it's value is not coprime with the value of lca(u,v). Here lca(u,v) means the lowest common ancestor of u and v.

You will be given Q queries. Every query contains two integers denoting two nodes,u and v. You have to find the count of special nodes in the simple path between u and v.

Теги codechef, queryt, #tree, #range query

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский mkitkat 2020-02-01 12:45:09 741 Initial revision (published)