2、3、5过不了,python

P5737 【深基7.例3】闰年展示

你闰年判断部分有误哦, 这行有问题 ```python if ((n % 400 == 0) or ((n % 4 == 0) and (n // 100 != 0))): ``` 应该改为 ```python if ((n % 400 == 0) or ((n % 4 == 0) and (n % 100 != 0))): ``` 即:将 ‘//’ 改为 ‘%’ 感觉你这样写麻烦了,我的ac代码如下(有不足欢迎补充、指正) ```python x,y=input().split() x=int(x) y=int(y) n=0 A=[] for c in range(x,y+1,+1): if (c%4==0 and c%100!=0) or c%400==0: n+=1 A.append(c) print(n) for i in A: print(i,end=' ') ```
by Math_Cai @ 2023-11-16 13:41:49


|