首页 > 解决方案 > 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中的大量数字有限制吗?

标签: python

解决方案


推荐阅读