The Multiplication

Nafis is working on a mathematical project. But he is stuck on a step of it. In this step, numerous multiplications need to be performed. He needs a lot of time to do this. But as there’s a shortage of time, there’s no scope of spending a lot of time on this one task. So, he is asking you to do the task in a short amount of time.

This is a companion discussion topic for the original entry at

Why my code got TLE?
Here is my code for this problem:

def multi(myList) :
    result = 1
    for x in myList: 
         result *= x  
    return result
t = int(input())
for i in range(t):
	x = 1
	while True:
		if x*k>n:
		x += 1
	print('Case '+str(i+1)+': '+str(multi(s)%(10**9+7)))

I optimize my code. But it got TLE.
Can anyone describe me why?

In each of the test cases, you are running a loop to calculate the answer. This is not well optimized. It is natural that you’re getting CLE verdict. See the editorial.
By the way, “227” in the editorial is actually “227”. I think that’s formating or typing mistake.

1 Like

Thanks, @ShadowMe! The editorial has been updated.