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

Auto comment: topic has been updated by Gilgamesh_01 (previous revision, new revision, compare).Constraints on n?

Oh sorry, 1<=n<=197

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)