A shortest path problem with mathematical twist

Revision en1, by 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.

Tags graphs, gcd, shortest path

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Heisenberg_71 2022-04-23 13:00:18 636 Initial revision (published)