A shortest path problem with mathematical twist

Правка en1, от Heisenberg_71, 2022-04-23 13:00:18

Given a undirected weighted graph with a source node and a destination node. The task is to find the shortest path between them.

But, their is a condition for choosing a edge for each time. Initially a number is given, X. An adjacent node can be only be visited if (X >= weight to reach the adjacent node to the current node) and after reaching any adjacent node the value of X changes to X = GCD(X, weight of edge that used to reach the current node).

There can be 10^5 nodes in the graph. weight of each edge can be 10^5 as well.

Can anyone provide a solution idea? Thank you.

Теги graphs, gcd, shortest path

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Heisenberg_71 2022-04-23 13:00:18 636 Initial revision (published)