hackerbaba's blog

By hackerbaba, history, 2 months ago, In English,

The submission link I tried uploading the following code for a problem statement. And got a runtime error for a large input of 400000 numbers. Could someone please help me understand. I am a bit new and hence am making these kind of mistakes.

no = int(raw_input()) nos = map(int, raw_input().split()) minNo = 10**13 for i in nos: if i < minNo: minNo = i div= [] # print(minNo) for i in range(1, (minNo)/2+2): if minNo % i == 0: div.append(i) div.append(minNo) # print(div) div=set(div) arrToRemove = [] for j in range(len(nos)): for i in div: if nos[j] % i != 0: arrToRemove.append(i) for t in arrToRemove: div.remove(t) print(len(div))
  • Vote: I like it
  • +5
  • Vote: I do not like it

2 months ago, # |
  Vote: I like it +5 Vote: I do not like it

You have cycle to ~ 10^11 (because minNo can be 10^12)

  • »
    2 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    But the numbers dividing the minNo will be equal to or less than or equal tominNo/2 and minNo. Right?