python - 为什么我在 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)
解决方案
这是因为对于您要解决的特定总和,输入可能在同一行中给出。IE。
20 50
您的代码需要一个接一个地输入:
20
50
尝试更改代码中的输入格式,如下所示:
withdrawal, balance = map(float, input().split())
推荐阅读
- python - 在 Django 和数据库中执行数学运算
- javascript - 如何在反应中使用单一方法仅扩展更多/更少一个 ListItem
- jquery - jQuery - 具有最大值的 handleCounter 范围设置
- react-native - 无法在 react-native 中解析 'uuid/v4'
- discord - 有没有办法对我当前的代码做出反应?(DiscordJsV12)
- python - 如何以十六进制字节解压/解码十六进制字符串?
- asp.net-core - 基于 body 的 ASP.NET Core 路由
- c# - 如何使用个人访问令牌使用 Libgit2sharp 身份验证
- c++ - 如何解决XAudio2.9虚拟音频设备问题?
- xcode - Xcode 12 Beta 2 - 无法为目标“arm64-apple-ios14.0-simulator”加载标准库