We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I tried this :
1/ find a diviser to n (call it n1) then the original number 111...11 can be divided by n1, and the result is like n2=1000...1000...1 (number of zeros dpend on n1)
then our original number
111...11 (n ones) = 11..1 (n1 ones)n2
Now 1000...1000....1 = 1000...1000...0 +1
1000...1000...0 can be divided by 1000... one can continue like this with some patterns to reduce the cost of % big numbers
But it didn't run all test cases :/ time exceeded
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Akhil and GF
You are viewing a single comment's thread. Return to all comments →
I tried this : 1/ find a diviser to n (call it n1) then the original number 111...11 can be divided by n1, and the result is like n2=1000...1000...1 (number of zeros dpend on n1) then our original number 111...11 (n ones) = 11..1 (n1 ones)n2 Now 1000...1000....1 = 1000...1000...0 +1 1000...1000...0 can be divided by 1000... one can continue like this with some patterns to reduce the cost of % big numbers But it didn't run all test cases :/ time exceeded