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.
# Enter your code here. Read input from STDIN. Print output to STDOUTt=int(input().rstrip())nums=[0]*(10**6)col=[0]*(10**6)max_nums=1nums[0]=1defenlarge_max(next_max):globalmax_numsglobalnumsglobalcol#nums[0] = 1#print("enlarging from {} to {}".format(max_nums, next_max))foriinrange(1,next_max+1):ss=int(max_nums/i)*i#if ss == max_nums:# nums[ss-1] += 1ss+=i#print("... i={} starting ss={}".format(i, ss))whiless<=next_max:#print(" cur ss={}".format(ss))nums[ss-1]+=1ss+=i#print("cur nums={}".format(nums[0:next_max]))#print("new max = {}".format(next_max))prev_col=col[max_nums-1]#print(" prev max = {} prev_col = {}".format(max_nums, prev_col))foriinrange(max_nums,next_max):#col[i-1] = prev_colifnums[i]==nums[i+1]:#print(" found equality at i={} {}={}".format(i, nums[i], nums[i+1]))prev_col+=1col[i]=prev_col#print(" arr equality={}".format(col[0:next_max]))max_nums=next_maxfor_inrange(0,t):k=int(input().rstrip())enlarge_max(k)print("{}".format(col[k-1]))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #179: Consecutive positive divisors
You are viewing a single comment's thread. Return to all comments →
Can anybody tell me what I'm missing?