Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

Given a natural number 'x' find minimum integer 'j' such that 'x*j' should have digits 4 and 0 only (only digit 4 is also allowed).

Revision en1, by Light71192, 2019-10-09 13:30:49

Here we have to print the value of 'x*j'. This problem was asked in my coding interview (Jaguar: Software Profile). Constraints were not mentioned in the problem.

This is the solution that I came up with : Code Explanation: I used a brute-force approach where I found all possible strings consisting of only 4 and 0 using bit-manipulation. Then I searched for the first number which gives : (number % x == 0) true.

It works for small inputs only. Please help me out with this problem and tell me if my approach is correct because I am unable to find any similar problem anywhere else. If possible suggest a similar problem so I can try my approach on that problem to see if it works or not.

Hints are also welcomed.

Tags #help, #c++, #beginner


  Rev. Lang. By When Δ Comment
en1 English Light71192 2019-10-09 13:30:49 921 Initial revision (published)