python - Python 计算数量限制(非浮点数)
问题描述
我正在做 codeforces 并发现大量,我的简单代码开始产生一些错误。
n = int(input())
for i in range(n):
candies = sum(map(int,input().split()))
if candies % 2 == 0:
print(int(candies/2))
else:
print(int((candies-1)/2))
当我把
1
9547116602436426 8316250877914575 2981260158260522
我预计会看到“10422313819305761”,但我得到的是“10422313819305760”。但在其他小数字中,在奇数和偶数的所有组合中,它工作得非常好。我也使用了 math.floor 而不是 if,但它给了我相同的答案。
python中的大量数字有限制吗?
解决方案
推荐阅读
- socket.io - 如何让 Socket.io 与 Svelte 一起工作?
- mongodb - Concat 两个聚合查询 MongoDB
- python - 如何在python中绘制不成比例的Y轴图形?
- windows - 如何从命令行停止 vlc
- javascript - 如何更改它以检测台式机而不是移动设备?
- c# - 用字符串括号内的分号替换逗号的最佳方法
- haskell - Haskell - 用另一个函数包装我的函数时出现统一问题
- r - 更新到 v1.63 后 spatstat rbind.hyperframe 崩溃
- asp.net-core - asp.net核心主机上的子域错误404
- reactjs - 反应.map不允许我迭代对象