#19770: 求助(Debug) - Python


songtzan (Clement)

學校 : 國立高雄師範大學
編號 : 107630
來源 : [218.173.4.238]
最後登入時間 :
2020-12-07 19:52:58

import sys
s = sys.stdin.readline().rstrip()

iCou = 1
while(s != ''):
   i01 = sys.stdin.readline().rstrip()   #rstrip 是消除 EOF
   i02 = sys.stdin.readline().rstrip()
   iLRan = int(i01)
   iRRan = int(i02)
   L = round(iLRan**(1/2)) -1
   R = round(iRRan**(1/2)) +1
   iSum = 0
   for x in range(L,R):
      if ((x**2) <= iRRan) and ((x**2) >= iLRan):
         iSum += x**2

   print('Case ' + str(iCou) + ': ' + str(iSum))
   iCou += 1

------ 以上是我的程式碼 ------

RE (code:1)

您的程式被監控系統中斷,可能是程式無法正常結束所導致。
Traceback (most recent call last):
  File "/5214266/code_5214266.py", line 8, in 
    iLRan = int(i01)
ValueError: invalid literal for int() with base 10: ''

------ 以上是我遇到的問題 ------

我想了很久不知道怎麼處理
我在 Python 內建的 IDE 測試是沒有問題的
感謝大家拔刀相助!!
#19771: Re:求助(Debug) - Python


asnewchien@gmail.com (david)

學校 : 南投縣立旭光高級中學
編號 : 68108
來源 : [114.42.176.221]
最後登入時間 :
2025-10-04 22:52:03


你的寫法是無窮迴圈。