We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The problem description feels impossible to understand, then I go to the editorial and i read the sentence:
"If it is, push it on to the second stack. If it is not divisible by the prime, push it on to the second stack."
Ok. I didnt get the problem, also dont get the editorial.
defwaiter(number,q):# Write your code hereprim=[]forjinrange(2,5*10**4):n=2whilej%n:n+=1ifn==j:prim.append(j)iflen(prim)==len(number):breakans=[]foriinrange(q):b=[]forjinrange(len(number)-1,-1,-1):ifnumber[j]%prim[i]==0:b.append(number[j])number.pop(j)number=number[::-1]ans+=b[::-1]returnans+number[::-1]
The problem description feels impossible to understand, then I go to the editorial and i read the sentence: "If it is, push it on to the second stack. If it is not divisible by the prime, push it on to the second stack." Ok. I didnt get the problem, also dont get the editorial.
¯^_(ツ)_/¯
As usual, when you see the completion percentage for a question go below 90% you can suspect that it's going to be a bit nasty...
This problem has two parts: generating the first 'q' primes, and then doing the plate sorting/stacking.
Python 3:
C#
JavaScript...