简体   繁体   中英

Why I am receiving a runtime error in Codechef?

I am getting runtime error(NZEC) on Codechef. Can anyone tell me why?

withdrwal = int(input())
balance = float(input())
amt = balance - withdrwal- 0.5
if (withdrwal%5!=0 or withdrwal+0.5>balance):
    print('%.2f'%balance)
else:
    print('%.2f'%amt)

It's because for the specific sum that you are solving, the inputs are probably given in the same line. ie.

20  50 

Your code expects inputs one after the other:

20
50

Try changing the input format in your code something like this:

withdrawal, balance = map(float, input().split())

Most probably you're trying to read input when there is no more input left to read and python raises an exception, the online judge in return gives the (NZEC) error. Try using raw_input() instead of input(). Comment back to let me know if it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM