Ad
  • Custom User Avatar

    M, changed to a single while loop just in case, though these while loops had O(sqrt(n)). After several attemts and combining factorials list with math function I got easy random tests and passed lol

  • Default User Avatar

    Oh, yes I know why. Your solution has a nested while loop(a while loop inside of another while loop.) That's O(n^2) time complexity, but O(n) time complexity won't time out.

  • Custom User Avatar

    Yeah, but I have tried to create a list of factorials from 0 to 1250, this should be enough for n and k ranges I see in logs. However, I get run out of time when find factorials with built-in math module function (and, what is more strange, I get is still, with getting factorials for o(1))
    I have some improvement in my mind, might help :)

  • Default User Avatar

    That's not the problem: you can't create a list of all the facatorials. There is a module called from math import factorial. Also, your solution should pass, it's just that list index out of range.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    In the task it is said k <= 100, but it can be up to 1000. Not clear :(