python - 为什么在两行上写 int(input()) 与一行不同?
问题描述
我正在编写代码来解决 CodeChef 上的以下问题:https ://www.codechef.com/problems/HS08TEST/
问题本身并不重要,我的问题是我提交了两个答案:
1:
x,y = input().split()
x = int(x)
y = float(y)
if x % 5 == 0 and x <= y - 0.50:
print(y - (x+0.50))
else:
print(y)
2.
x = int(input(x))
y = float(input(y))
if x % 5 == 0 and x <= y - 0.50:
print(y - (x+0.50))
else:
print(y)
正如你所看到的,除了 x 和 y 的初始化之外,一切都是一样的——当第一批代码被接受时,第二批代码遇到了 NZEC 运行时错误。知道两者之间有什么区别吗?是因为 CodeChef 网站插入输入的方式吗?
解决方案
推荐阅读
- jquery - 触发Flask路由后jQuery不重定向
- scala - 在 scala 中使用前导零和逗号而不是小数点格式化字符串的最有效方法
- authentication - 如何使用 RxJava 进行同步调用
- node.js - 使用 Nodejs 快速发布
- python - PyTorch - 参数不变
- python - openpyxl图表和表格设计
- qt - Qml 覆盖 OnCustomValueChanged
- swift - NSMutableAttributedString:如何检索范围内的属性
- c++ - 项目文件包含 ToolsVersion="15.0"。此工具集可能未知或缺失
- python - Django 为特殊的人创建课外班