T = 0 while True: if X > T and T ==0: if L[-1]*(X-T) == Y: break else: T += 1 elif X > T and T >=1: if L[-1]*(X-T) + sum(L[(-1)-i] for i in xrange(T+1) if i > 0): break else: T += 1 elif X <= T: if sum(L[(-1)-i] for i in xrange(T-X,T+1) ) == Y: break else: T += 1
MarioLuisGarcia
2014-07-30 18:38:43 +08:00
indentation因为v2ex显示问题不对了。
MarioLuisGarcia
2014-07-30 18:40:06 +08:00
T = 0 while True: if X > T and T ==0: if L[-1]*(X-T) == Y: break else: T += 1 elif X > T and T >=1: if L[-1]*(X-T) + sum(L[(-1)-i] for i in xrange(T+1) if i > 0): break else: T += 1 elif X <= T: if sum(L[(-1)-i] for i in xrange(T-X,T+1) ) == Y: break else: T += 1
@qsl0913 oh my god, 难道我要用 来缩进代码? @天!
MarioLuisGarcia
2014-07-30 19:06:17 +08:00
T = 0 while True: if X > T and T ==0: if L[-1]*(X-T) == Y: break else: T += 1 elif X > T and T >=1: if L[-1]*(X-T) + sum(L[(-1)-i] for i in xrange(T+1) if i > 0): break else: T += 1 elif X <= T: if sum(L[(-1)-i] for i in xrange(T-X,T+1) ) == Y: break else: T += 1
MarioLuisGarcia
2014-07-30 19:06:36 +08:00
...从stackoverflow辅助过来也不行。。。
MarioLuisGarcia
2014-07-30 19:07:20 +08:00
T = 0 while True: * if X > T and T ==0: * if L[-1]*(X-T) == Y: * break *else: * T += 1 * elif X > T and T >=1: * if L[-1]*(X-T) + sum(L[(-1)-i] for i in xrange(T+1) if i > 0): * break *else: * T += 1 * elif X <= T: * if sum(L[(-1)-i] for i in xrange(T-X,T+1) ) == Y: * break *else: * T += 1