首页 > 解决方案 > 为什么我在 Codechef 中收到运行时错误?

问题描述

我在 Codechef 上收到运行时错误(NZEC)。谁能告诉我为什么?

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)

标签: python

解决方案


这是因为对于您要解决的特定总和,输入可能在同一行中给出。IE。

20  50 

您的代码需要一个接一个地输入:

20
50

尝试更改代码中的输入格式,如下所示:

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

推荐阅读