A group of thieves steal only money. Every morning they deposit the money to their leader. The leade…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
I used 2 different codes, but both of the time, CLE error took place. Anyone to help?
def prod(list):
p = 1
for j in list:
p *= j
return p
n=int(input())
k=[]
m=list(map(int, input().split()))
for i in range(n):
b=m[:i]+m[(i+1):]
k.append(prod(b))
print(*k)
and,
n=int(input())
p=[]
m=list(map(int, input().split()))
for i in range(n):
b=m[:i]+m[(i+1):]
l=1
for j in b:
l*=j
p.append(l)
print(*p)
@rased_299, I see that you were able to solve the problem. So, I am skipping your question. @Rafeed, You are getting CLE because your code is not efficient. Try to figure out a more efficient approach to solve the problem.
And again, Both of your codes has the same logical approach. So, it does not count.
def mulpti():
temp5 = b * c * d
temp6 = a * c * d
temp7 = a * b * d
temp8 = a * b * c
def somthing():
if temp5 <= 2 ** 31 and temp6 <= 2 ** 31 and temp7 <= 2 ** 31 and temp8 <= 2 ** 31:
print(temp5, temp6, temp7, temp8)
somthing()
d = int(input())
a, b, c, d = map(int, input().split())
if a <= 105 and b <= 105 and c <= 105 and d <= 105:
mulpti()