log in
About and Contact
© 2020 DOUBTCOOL
Python code
# cook your dish her
a=[]
c=0
for t in range(int(input())):
n=int(input())
if n<=50:
n=50
elif n<=1:
n=1
a=list(map(int,input().split()))
a=set(a)
a=list(a)
h=min(a)
n=len(a)
for j in range(n):
if a[j]>h:
c+=a[j]//h-1
print(c)
Can anyone comment on why print (len(set(a))) cannot be a answer to this problem ? where a is the array of
the length of sticks.
The answer can be print(len(set(a)))
print(len(set(a)))
Python Code:-
a=[]
c=0
for t in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
while(sum(a)!=0):
sa=set(a)
la=list(a)
la.sort(reverse=True)
h=la[1]
for i in range(len(a)):
if(h<a[i]):
a[i]=a[i]-h
c+=1
print(c)
Try This as per guest commented
for t in range(int(input())):
n=int(input())
if n<=50:
n=50
elif n<=1:
n=1
a=list(map(int,input().split()))
print(len(set(a)))