提问人:Rakesh Verma 提问时间:8/7/2015 最后编辑:Rakesh Verma 更新时间:8/7/2015 访问量:60
在 ideone 上获得无限的“错误答案”作为输出
Getting infinite "wrong answer" as output on ideone
问:
import sys
def carton(x):
bottle=x/10
rem=x%10
if rem > 7:
bottle = bottle + rem + 1
elif rem == 7:
bottle = bottle + 1
elif 5<rem<7:
bottle = bottle + 2
elif rem == 5:
bottle = bottle + 1
elif rem<5:
bottle = bottle + rem
print (bottle)
def carton_small(x):
bottle = 0
if x > 7:
bottle = bottle + x%7 + 1
elif x == 7:
bottle = bottle + 1
elif 5<x<7:
bottle = bottle + 2
elif x == 5:
bottle = bottle + 1
elif x<5:
bottle = x
print(bottle)
while True:
test = sys.stdin.read()
try:
test = int(test)
except ValueError:
print ("no, wrong data")
continue
except EOFError:
print ("no,EOF")
continue
if not test: break
break
for x in range(test):
while True:
bottle = sys.stdin.read()
try:
bottle = int(bottle)
except ValueError:
print ("no, wrong data")
continue
except EOFError:
print ("no, EOF1")
continue
if not test: break
break
if(bottle>10):
carton(bottle)
elif(bottle<10):
carton_small(bottle)
else:
bottle = 1
print (bottle)
我写了代码来检查送奶工携带 x 升牛奶所需的最小瓶子数量。瓶子的尺寸只有 {1,5,7,10} 升。在我的系统上一切正常,但在 Ideone 上,我无限地收到 valueError 异常中定义的错误。请帮忙吗? 我确定问题是因为这里的sys.stdin.readline(),因为输入做得很好,但我猜ideone不接受input()。
答: 暂无答案
评论