Блог пользователя Lara_Croft

Автор Lara_Croft, история, 9 лет назад, По-английски

I looked up everywhere but couldn't find a tutorial for this gym contest (VIII Open Programming Championship of Kazan Federal University 2015), and so I'm stuck at problem J Polycarp and Dividend. It looks easy but I couldn't find the solution. Could anyone help me or at least give me a hint?

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Construct a graph with A vertices, each representing its number. From any vertex, can go to any vertex with number CurrentVertexNumber * 10 + a[i] mod A for i < n, where a is the array of usable digits. Now your task is to find the shortest path from vertex 0 to vertex 0 (A mod A) and print that path.
Beware from starting with digit zero.
Good luck!