c++ - Find total number of 1s -
given number n, find total number of 1s present in pow(11, n) 1 < n < 1000,000. solving using basic approach land overflow issues since n large. ways can solve efficiently?
see calculate count of ones in result of 11^n
multiplication 11 equal multiplication 10 (i.e. putting 0 right of number) , adding original number. using can work strings, , don't need additional library.
Comments
Post a Comment