#25237: TLE怎解決?????


10755006@st.chjhs.tp.edu.tw (FF)

學校 : 不指定學校
編號 : 146412
來源 : [210.243.21.253]
最後登入時間 :
2021-11-12 14:43:23
d485. 我愛偶數 -- 板橋高中教學題 | From: [101.137.199.121] | 發表日期 : 2021-05-02 11:34

a,b =map(int,input().split())
tot = 0
for x in range(a,b+1):
    if x % 2 == 0:
        tot = tot + 1
print(tot)
 
#25238: Re:TLE怎解決?????


fire5386 (becaidorz)

學校 : 國立清華大學
編號 : 115822
來源 : [140.114.217.8]
最後登入時間 :
2024-04-13 22:06:23
d485. 我愛偶數 -- 板橋高中教學題 | From: [114.44.1.89] | 發表日期 : 2021-05-02 11:50

a,b =map(int,input().split())
tot = 0
for x in range(a,b+1):
    if x % 2 == 0:
        tot = tot + 1
print(tot)


用數學算 你這樣迴圈跑那麼多次一定會超時

 
ZeroJudge Forum