• + 0 comments

    This was kinda hard man jesus. The key insight: simplify x, factoring out every 5 and 2 from it. You have to find the smallest a such that 444... (of length a) is divided by the simplified x - you can do all these computations modulo simplified x, i.e. start at 0, multiply-by-10-then-add-4, reduce modulo simplified x until you get 0, the amt of iterations this took is the value of a. using the 2's and 5's you factored at the start (+the knowledge that the 4... number has no 5 factors and 2 2 factors) you can figure out the amt of 0s you need. Repeat this for some other values of a (up to a+b for the first pair you find) to ensure you find the one w the smallest (a+b, a) lexicographically and that's the solution.