710

This is quite an easy problem. But it took me long time to realize that to determine the number of total game segments is nothing but counting the direction changes to reach the destination.

 

677

 

633

 

627

There is another solution using Linked List in case Router ID is not limited from 1 to 300. But for this problem this solution gets TLE.

   

599

 

590

 

11734

 

11934

Have some idea about Remainder Theorem, not necessary to solve the problem but it is good to revise some theorem.

 

11936