python 2.7 - Why round(15.0)==15.0 is false? -
- input 4 integer
n
,x[0]
,x[1]
,x[2]
n = a*x[0] + b*x[1] + c*x[2]
,n<=4000
findmaxi = a+b+c (a,b,c>=0)
when ran
n=3164
,x = [42, 430, 1309]
. answer must 15. whyround(15.0)==15.0
false? found when tried printi, 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
Post a Comment