Sort by

recency

|

7 Discussions

|

  • + 0 comments

    Python3 solution

    from functools import reduce
    
    def baseconv(n, b):
        newbase = []
        if n < b:
            return 0
        if n == b:
            return [1]
        while True:
            r = n % b
            newbase.insert(0, r)
            n = n // b
            if n == 0:
                break
        return newbase
    
    t = int(input())
    for i in range(t):
        n, p = map(int, input().split())
        base = baseconv(n, p)
        nonzeros = reduce(lambda x, y: x * y, (z + 1 for z in base))
        print(n - nonzeros + 1)
    
  • + 0 comments

    It is a pleasant assortment of some delightful animals. I am appreciative to the organization of the site because of which I am viewing the delightful post and amazing service that is rush my essay legit to help weak students . Continue accomplishing this work. I like it without question.

  • + 0 comments

    Great information guys, Keep sharing im not into maths but i like maths. Please visit our website once i hope it will be useful for you guys. Accounting Services LLP Registration India LLP Registration Bangalore.

  • + 0 comments

    Want to be rich, don't worry too much We can help pgslot

  • + 5 comments

    hey i need some hints.. i am having problem with such large n..