You are viewing a single comment's thread. Return to all comments →
dp solution passes 7 test cases but tle for greater than 10^7 input
op=[] def generate_decibinary(n): l=[int(i) for i in list(str(n))] m=len(l) dp=[0 for i in range(m+1)] for i in range(m-1,-1,-1): dp[i]=dp[i+1]+l[i]*2**(m-i-1) op.append([n,dp[0]]) t=int(input()) ip=[] for _ in range(t): n=int(input()) ip.append(n) for i in range(0,1000000): generate_decibinary(i) op=sorted(op,key=lambda x:x[1]) for i in ip: print(op[i-1][0])
Seems like cookies are disabled on this browser, please enable them to open this website
Decibinary Numbers
You are viewing a single comment's thread. Return to all comments →
dp solution passes 7 test cases but tle for greater than 10^7 input