腾讯笔试,红花白花那题,一直提示,语法错误或数组越界非法访问
腾讯笔试,红花白花那题,我怎么提交,都提示,语法错误或数组越界非法访问,求大家帮我看看到底什么问题,暂时先不考虑复杂度高的问题,谢谢谢谢。
import sys def jiecheng(ttt): s = 1 for iii in range(1, ttt+1): s *= iii return s if __name__ == "__main__": line1 = sys.stdin.readline().strip() line11 = list(map(int, line1.split())) n = line11[0] k = line11[1] if n == 0: print(0) nums = [] res = [] for i in range(n): line2 = sys.stdin.readline().strip() line22 = list(map(int, line2.split())) nums.append(line22) for i in range(n): start = nums[i][0] end = nums[i][1] if k == 0: res.append(0) continue count = 0 for j in range(start, end+1): t = 0 while t * k <= j: hong = j - t*k temp = jiecheng(t + hong) / jiecheng(t) / jiecheng(hong) count += temp t += 1 res.append(int(count)) for res_i in res: print(res_i)