python 2.7 - Why round(15.0)==15.0 is false? -


  1. input 4 integer n, x[0], x[1], x[2] n = a*x[0] + b*x[1] + c*x[2] , n<=4000 find maxi = a+b+c (a,b,c>=0)
  2. when ran n=3164, x = [42, 430, 1309]. answer must 15. why round(15.0)==15.0 false? found when tried print i, j, tf, ti, maxi in line 17:

    x = [0, 0, 0] n, x[0], x[1], x[2] = map(float, raw_input().split()) x.sort(reverse=true) #suppose x[0]>=x[1]>=x[2] maxi=0  if x[2] == 1.0:     print int(n)  else:     in range(int(n/x[0])+1):      #first loop find a: <= n/x[0]         j in range(int(n/x[1])+1):  #second loop find b: b <= n/x[1]             #used math find equation found:             tf = float(i*(1.0-x[0]/x[2]) + j*(1.0-x[1]/x[2]) + n/x[2])             ti = int(round(tf))             if tf > n or tf <0:                 break              if ti==tf , ti >= maxi: #find satisfactory value                 maxi = ti              #print i, j, ti, tf, maxi     print maxi 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -