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

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

Hi everyone, I need help with this problem, I tried 3 days, but nothing work. The problem consists about find the x smallest múltiple of a number n, and x only consists of 0 and 1 for example n=2,x=10 and n=3,x=111.. please help I try brute force but it doesn't work

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

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

Constraints on n?

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

Maybe bfs works? Make $$$n$$$ points, denoting the remainder when $$$x$$$ modulo $$$n$$$ is $$$i$$$. We start bfs from 1, and find the shortest path to 0.

At the same time, note that when extending points, first add the point when using 0, then using 1.

(Inspired from 1209F)